Reputation: 9654
This is my script:
CREATE DATABASE mydbname;
USE mydbname;
If I run 1st line, then 2nd line, it works OK.
If I run both together then I get this error:
Msg 911, Level 16, State 1, Line 3
Database 'mydbname' does not exist. Make sure that the name is entered correctly.
What is the correct way to write this script?
Upvotes: 0
Views: 126
Reputation: 7656
Use GO
inbetween:
CREATE DATABASE mydbname;
GO
USE mydbname;
Upvotes: 2