Reputation: 15394
I would like to make sure that a series of commands are executed in a serial way, like in
update TABLE1...
update TABLE2...
update TABLE3...
I would like that update TABLE2
starts only when update TABLE1
has completed.
Of course I can do this with GO:
update TABLE1...
GO
update TABLE2...
GO
update TABLE3...
GO
But in this case i will lose all the local variables.
Is there an easy way to perform what I need? Thanks.
Upvotes: 3
Views: 8501
Reputation: 17090
Next command in your batch will begin only after the previous one has finished. No need to do anything, this is how it works. What is the problem you are solving?
Edit: your "cannot recreate index, it already exists" error occurs at compilation, not during running - your index exists when your batch is being compiled. GO breaks your script into separate batches, which compile only after the previous batch completed.
Upvotes: 3
Reputation: 40160
You don't need GO to do that; GO simply causes a batch to be sent to the server at that point. As long as you put the commands sequentially in one script, they will execute one-after-another just as you wish. You would have to do extra work to get them to run in parallel
Upvotes: 3