Comment character in editor for plain SQL?

Hi, I am a new LINQpad user. I see how to comment out C# code while I'm doing queries, but how can I comment out plain SQL code in the editor? I'm using the "LINQ to DB" driver, but I'm hoping the issue is an editor thing because the editor must pass the SQL to the driver.

I have tried these comment styles: '//', '/* ... */', and '--' (which is what the default ctl-k,c shortcut gives me).

Is there any way to comment out some SQL statements in the editor buffer, or am I limited to a single SQL statement (and no comments) in the buffer?

Thank you

Comments

  • Either /* */ or --

    If your language is set to SQL, then it is bypassing the LINQ to DB driver

    As an example, I have used https://raw.githubusercontent.com/amachanic/sp_whoisactive/master/who_is_active.sql to create sp_WhoIsActive stored procedure.

  • Hi, thank you for your reply. Here's two screenshots showing that I do have my language set to SQL and I still get the error with both comment syntaxes

  • Access doesn't support comments in SQL

  • edited December 2019

    Thank you. It's true that I can't use comments in the Access queries either. I surmise that this means the LINQpad editor does not make any attempt to strip comments before sending off the query.

    It seems to me that it would be VERY easy and simple for the LINQpad editor to strip comments before sending the query to the driver. And very useful, too. (I hope LINQpad considers stripping comments - it would be very easy to do. When you're writing in a scratch pad, you're constantly commenting/uncommenting different versions of the code under test.

    But with no commenting allowed, I guess the only route is to continually copy/paste back and forth between Notepad and LINQpad. Oh well. For the premium product that I just bought, I think LINQpad could do better in this regard. :-)

  • Personally I would be very unhappy if LINQPad decides to modify the query I pasted in the SQL tab.

    Perhaps you could program your queries in the C# tab.. this way you can both use literal SQL, comments and any .NET framework functionality in C#.

    // Query 1
    this.ExecuteReader(@"SELECT *
    FROM Table1").Reader.Dump();
    
    // Query 2
    this.ExecuteReader(@"SELECT *
    FROM Table2").Reader.Dump();
    
  • edited December 2019

    @nescafe Thank you for taking the time to post the nice workaround in C# mode for Linqpad. It's a nice bypass and works very well, so my immediate problem is solved.

Sign In or Register to comment.