June 1, 2009 at 1:35 am
I have maintained 20 database on one server.
To update all these 20 database I have created one script.
scripts contains create table and Stored Procedures statements.
By mistake I have run this script on Master Database.
Any way to easily DROP all this un neccesary objects from master database.
June 1, 2009 at 2:06 am
View > Object Explorer Details - select the objects you want to delete, right-click, and delete.
In future, make sure you have the right execution context before running a script. Next time it might be a DROP TABLE and you're running on Production.
June 2, 2009 at 11:10 am
Put a safety check at the beginning of your script. We have to do the same thing (i.e., upgrade 100+ databases with a new release). To avoid accidental schema creation or schema upgrade into a "system" database the following is at the start of my script:
SELECT CAST('Target Database is: ' + DB_NAME() AS VARCHAR(70));
GO
IF UPPER(DB_NAME()) IN ('MASTER', 'MODEL', 'MSDB')
RAISERROR('Invalid database for schema creation.', 16, 1);
GO
June 2, 2009 at 12:58 pm
Nice tip, John! I'm going to use it myself 🙂
June 2, 2009 at 1:09 pm
Randolph Potter (6/2/2009)
Nice tip, John! I'm going to use it myself 🙂
You're welcome. It is one of numerous defensive measures that I've implemented. Usually resulting from the school of "hard knocks".
Just make sure that you use the -b (on error batch abort) switch when you run your script using SQLCMD.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply