How to add comments in SOQL

No, I don't think there's a way to use comments in SOQL. You can comment out pieces of queries you've issued in Apex though.

There are some tools that you might like more than the official Flash-based Explorer and the sluggish querying utility in Eclipse IDE.

My favorite is Real Force Explorer - has the searchable history of SOQL and Apex snippets, you can select the piece you want to run if you have several queries (like in Oracle's SQLDeveloper)...

I've heard some good stuff about BrainEngine too, didn't try it yet (basic version is free, cough up cash for more). The screenshots look tempting ;)

You might also like web-based tools like the official Workbench - if you're not a fan of providing the credentials in the officially hosted one you can download it and host it on your own machine.

Last but not least - JitterBit Data Loader got promoted some time ago to be listed in Setup pages. Haven't played with it either (might be it's just a data loader, not really suited for query editor tasks).

If you're SQL Server guy - have a look at DBAmp ($$$ again). I doubt it's the only connector to Salesforce, there have to be some more ODBC-like translation attempts. So you might be able to find a plugin for your favorite SQL editor after all.

(no, I'm not related to any of companies or projects behind these links)


If you are writing inline SOQL inside of Apex, you can add Apex comments. Both block and single-line comments work.

You can verify this in the Execute Anonymous Window in the Developer Console:

List<Account> accounts = [
    SELECT ID From Account
    // single line comment
    WHERE Name = 'Test' /* block comment */
];

The Execution log shows that the comments are removed from the actual query:

SOQL_EXECUTE_BEGIN [1]|Aggregations:0|SELECT ID FROM Account WHERE Name = 'Test'