T-SQL Rant

Time to rant a little about 'GO'

I have a SQL script (created from enterprise manager) that I wanted to call from a windows form to create a database on a local instance of SQL server. After about 30 minutes of trying to get it to work I figured out that the problem was 'GO'. GO only works for apps such as query analyzer and enterprise manager.

I was reading the file in a steamreader, and then trying to run that code using the data application blocks executenonquery.

To get around this I just pass the file in question to an OSQL command, and let it run outside of my application, while my application waits for it to finishing running before allowing the user to complete the next step.

The little frustrations you face every day developing, I love figuring things like this out, makes the day much more interesting.


  • the reason "GO" works in Query Analyzer is because QA knows that this word means "execute the above statements". so - whenever QA sees the word "GO", it actually strips it out of the code that is being executed.

  • GO is a batch terminator for query analyzer; just split into an string array around instances of the GO word and walk the array executing each cell!

  • I actually thought of the array this afternoon on my way home. I have my app working as it needs to for now though, so I'll probably leave it as is while I complete other portions of the application, and come back later to work out this issue.

  • While I was ranting about GO not working with t-sql, I was not complaining about Microsoft or the lack of any tools.

    I was merely commenting on the things I admit I do not know, that is part of what I like about what I do, I learn new things every day.

    I may not have the knowledge that other have, but I have never claimed to be that "gifted" and enjoy learning those things I do not know.

    Rant about me if you wish, but I never stated anything negative about anyone, or any tool, only that I did not know something, I learned about it by running into a problem, and next time I will know.

Comments have been disabled for this content.