views:

58

answers:

1

I can't get this script to run, because SQL management studio 2008 says the table "NewName" does not exist. However, the script's purpose is to rename an existing database, so that it does exist when it gets to that line. Ideas?

Use Master;

ALTER DATABASE OldName SET SINGLE_USER WITH NO_WAIT;
ALTER DATABASE OldName MODIFY NAME = NewName;

ALTER DATABASE NewName SET MULTI_USER;
Use NewName; --THIS LINE FAILS BEFORE THE SCRIPT EVEN RUNS!
+7  A: 

Add GO between the 2nd and 3rd ALTER DATABASE statements.

http://msdn.microsoft.com/en-us/library/ms188037.aspx

Jon Seigel
Yes, it is this simple :)
ck
I could have sworn this didn't work for me the other day - but attempting to disprove you.... it worked! :-) +1
marc_s