Help: SQL Server

Sharing my knowlege about SQL Server Troubleshooting Skills

    Advertisements
  • Blog Stats

    • 1,569,050 hits
  • Select GETDATE()

    February 2019
    M T W T F S S
    « Apr    
     123
    45678910
    11121314151617
    18192021222324
    25262728  
  • Advertisements

Posts Tagged ‘incorrect syntax near go’

Troubleshooting : Error – Incorrect syntax near ‘GO’

Posted by blakhani on August 28, 2014


Sometimes we are very comfortable and used to with certain things that if they change, we become nervous and uneasy. I have a lovely daughter and she always greets me when I come back home from office. That one “hello” takes away all my worries and I feel alive. Yesterday she didn’t do that and I was worried. I checked with my wife and she told that there was a mild fever and her mood is little different today. That made me little nervous.

Same feeling happened when I saw below in management studio of my colleague:

Msg 102, Level 15, State 1, Line 2

Incorrect syntax near ‘GO’.

image

 

and management studio intellisense feature was also complaining about syntax. “Incorrect syntax near ‘End Of File’. Expecting ‘=’. As per documentation “GO is not a Transact-SQL statement; it is a command recognized by the sqlcmd and osql utilities and SQL Server Management Studio Code editor”

I went to Tools > Option in Management studio and found that there was a customization done on batch separator. SSMS> Tools > Options >Query Execution > SQL Server > General > Batch Separator.

Which means if I run with “come” it should work and as expected.

image

Perfect! This mystery is solved now. This made me think that can we customize SQLCMD as well. If we look into help of SQLCMD we can see parameter -c cmdend

image

Here is the usage of parameter –c . I have used hello as command end parameter and hello works same as go in true sense.

image

I hope this clears some confusion about batch separator.

If you are getting this error while using ExecuteNonQuery in .net program and running script then refer http://blogs.msdn.com/b/onoj/archive/2008/02/26/incorrect-syntax-near-go-sqlcommand-executenonquery.aspx which has a workaround.

Hope this helps!

  • Cheers,
  • Balmukund Lakhani
  • Twitter @blakhani
  • Author: SQL Server 2012 AlwaysOnPaperback, Kindle
  • Advertisements

    Posted in SSMS, Troubleshooting | Tagged: , , , , , , | 2 Comments »