SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


by mistake one Script on Master


by mistake one Script on Master

Author
Message
mayank jarsaniya
mayank jarsaniya
SSC Eights!
SSC Eights! (886 reputation)SSC Eights! (886 reputation)SSC Eights! (886 reputation)SSC Eights! (886 reputation)SSC Eights! (886 reputation)SSC Eights! (886 reputation)SSC Eights! (886 reputation)SSC Eights! (886 reputation)

Group: General Forum Members
Points: 886 Visits: 427
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.
Randolph West
Randolph West
Mr or Mrs. 500
Mr or Mrs. 500 (574 reputation)Mr or Mrs. 500 (574 reputation)Mr or Mrs. 500 (574 reputation)Mr or Mrs. 500 (574 reputation)Mr or Mrs. 500 (574 reputation)Mr or Mrs. 500 (574 reputation)Mr or Mrs. 500 (574 reputation)Mr or Mrs. 500 (574 reputation)

Group: General Forum Members
Points: 574 Visits: 440
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.
Mauve
Mauve
Hall of Fame
Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)

Group: General Forum Members
Points: 3438 Visits: 2066
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




(PHB) I think we should build an SQL database. (Dilbert) What color do you want that database? (PHB) I think mauve has the most RAM.
Randolph West
Randolph West
Mr or Mrs. 500
Mr or Mrs. 500 (574 reputation)Mr or Mrs. 500 (574 reputation)Mr or Mrs. 500 (574 reputation)Mr or Mrs. 500 (574 reputation)Mr or Mrs. 500 (574 reputation)Mr or Mrs. 500 (574 reputation)Mr or Mrs. 500 (574 reputation)Mr or Mrs. 500 (574 reputation)

Group: General Forum Members
Points: 574 Visits: 440
Nice tip, John! I'm going to use it myself :-)
Mauve
Mauve
Hall of Fame
Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)

Group: General Forum Members
Points: 3438 Visits: 2066
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.


(PHB) I think we should build an SQL database. (Dilbert) What color do you want that database? (PHB) I think mauve has the most RAM.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search