Looking at the msdn, there was an example on “GO” command. Why there is:
USE somedb
GO
...
...
It it neccesary to select db in different batch? Thanks for explanation!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No, however, some commands have to be the first statement in the batch.
Examples include
CREATE VIEW,CREATE PROCEDUREandCREATE TRIGGER.Thus if you want to do:
Then you need to do:
If you are only running one
USE DBstatement, theGOhas no usefulness.Some commands do not require that they are the first statement in a batch:
Sometimes in code generation, all the GO commands might not be necessary, but it’s just easier to generate them.