I'm trying to write a T-SQL script to create a database and the corresponding tables. I'm having a problem where the USE
statement complains that the database that I just "created" doesn't exist. If I run the script within SQL Server Management Studio so that I can make use of the GO
statement, I don't get this issue.
Is there a T-SQL equivalent of GO that I can use to make sure the CREATE DATABASE
gets executed before the USE
?
I've tried BEGIN
/COMMIT TRANSACTION
and BEGIN
/END
but they didn't help.