Reputation: 6530
I am working on SQL Server 2005 and I have come accros the issue that I have run the multiple update query on the single table one by one. As it takes lots of time to execute one by one I came to know that by using "GO" I can run the query one by one. Like this
Update Table A ....
GO
Update Table A
GO
Update Table A
I am not sure that I can put seperate update statement like this and it will run the query one by one. As I doing it on production I need to be sure that it should work.
Can anyone give me an example where I can see that by using GO, query runs one by one and not parallel?
Upvotes: 1
Views: 1072
Reputation: 40149
Your queries will not be run in parallel whether or not you use the GO
command. astander posted an answer explaining what GO
is. Read that, then come back here.
Regardless whether you use the GO
command, your script will be run one-statement-after-another. They are not run in parallel.
You can prove this by writing a script such as this (pseudo code, but you get the idea)
INSERT INTO MyTable ([id], [data]) VALUES (3, 'I am here')
DELETE FROM MyTable WHERE [id]=3
You can put a GO
between those statements or not, the result will be the same: the first command will -always- fully complete before the second one is run.
Upvotes: 2
Reputation: 166346
From GO (Transact-SQL)
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.
SQL Server utilities interpret GO as a signal that they should send the current batch of Transact-SQL statements to an instance of SQL Server. The current batch of statements is composed of all statements entered since the last GO, or since the start of the ad hoc session or script if this is the first GO.
Upvotes: 4