I found this example here
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=138165
CREATE TABLE #MessageLog
(
MessageText VARCHAR(MAX),
MessageDateTime VARCHAR(MAX),
MessageAuthor VARCHAR(MAX),
IncidentNumber INT
)
CREATE TABLE #Incident
(
id INT,
[description] VARCHAR(30),
IncidentNumber INT
)
INSERT INTO #MessageLog (MessageText, MessageDateTime, MessageAuthor, IncidentNumber )
SELECT 'masg1 'MessageText, GETDATE()-6 MessageDateTime,'abc' MessageAuthor, 4 IncidentNumber
UNION ALL
SELECT 'msg 2'MessageText, GETDATE()-6 MessageDateTime,'abc' MessageAuthor, 4 IncidentNumber
UNION ALL
SELECT 'msg3'MessageText, GETDATE()-6 MessageDateTime,'abc' MessageAuthor, 3 IncidentNumber
INSERT INTO #Incident
SELECT 1, 'desc', 4
UNION ALL
SELECT 1, 'desc', 4
UNION ALL
SELECT 1, 'desc', 3
-- the solution
SELECT STUFF(( SELECT '------------' + CHAR(13) + CHAR(10)
+ MessageLog.MessageText + CHAR(13) + CHAR(10)
+ '- on ' + MessageLog.MessageDateTime + ' by '
+ MessageLog.MessageAuthor + CHAR(13) + CHAR(10)
FROM #MessageLog MessageLog
WHERE Incident.IncidentNumber = MessageLog.IncidentNumber
ORDER BY MessageLog.MessageDateTime DESC
FOR XML PATH (''),TYPE ).value('.[1]','varchar(max)')
, 1, 2, '') AS allMessages
FROM #Incident Incident
The short answer is no, it cannot be turned off.
GO is a 'batch terminator'. When SSMS executes 'statements' they are 'batched' together. This could be a single query, an entire script with no 'GO's or could be the code between 'GO's.
That is why you are getting the errors when you are trying to add a column and update it in one hit. They need to execute as separate batches.
It is also possible that, say you had 3 statements separated into batches that a single batch in a script could fail but not the entire script.
Query1 -- success
GO
Query2 -- failed
GO
Query3 -- success
GO
GO is not a Transact SQL Statement, it is a command recognised by SSMS and sqlcmd. See here on MSDN for more details.
You will also find that variables do not persist past a GO statement and must be re-declared or your statement/batch sequence amended.
Incidentally, you don't have to use 'GO' as a batch terminator, you could use anything. It can be amended from the Tools-->options menu, under query execution. Be aware though, changing it and using something different will only work for the copy of SSMS you are using. If you are working in a team, and every member of the team has not changed to use 'NewBatch' keyword then the script will fail in their copy of SSMS (as I'm fairly confident it does in sqlcmd too!).
Best Answer
In SQL Server Management Studio (SSMS) there is a command to Delete Blank Lines, though it is not available on a menu, toolbar icon, or keyboard shortcut by default.
If you have to do this regularly, edit your menus, toolbars, or shortcuts to add this command. For example, to add this command to the Edit/Advanced menu:
From the Tools menu, choose Customize:
In the window that appears, choose the Commands tab, then drop down the Menu Bar list to select Edit | Advanced:
Then click Add Command
Now select the Edit category and scroll the Commands list to select Delete Blank Lines:
Once this is done, Delete Blank Lines will appear in the Edit/Advanced menu. There are other options in the Customize dialogs shown above to position the command in the menu, add a keyboard shortcut, or add an icon for it to a toolbar.