1

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?

2
  • If you are not sure about them ,then run each update separately.. Commented Oct 7, 2010 at 6:30
  • Thanks Srini but I have several update statement and most of them are on the same table. and they take different time to execute so I thought to make a sequencial run instead of waiting and doing it manual one by one. Commented Oct 7, 2010 at 6:36

2 Answers 2

4

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.

Sign up to request clarification or add additional context in comments.

2 Comments

As I am using SQL Server management studio, does it means that it will execute these update statement seperately ?
@Andrew Barber, please be aware that GO is an SSMS command, not TSQL, as I stated. So I think the best would be to get GO out of your mind entirely if you can X-)
2

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.