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


Dropping a database


Dropping a database

Author
Message
rsharma
rsharma
Old Hand
Old Hand (389 reputation)Old Hand (389 reputation)Old Hand (389 reputation)Old Hand (389 reputation)Old Hand (389 reputation)Old Hand (389 reputation)Old Hand (389 reputation)Old Hand (389 reputation)

Group: General Forum Members
Points: 389 Visits: 185
Comments posted to this topic are about the content posted at http://www.sqlservercentral.com/columnists/rsharma/droppingadatabase.asp
pattikay
pattikay
Grasshopper
Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)

Group: General Forum Members
Points: 11 Visits: 2
Hi Rahul,
I will find the script very useful,tho i have one question,
what are u executing when u said :
EXEC SetMessages

Thanks.



rsharma
rsharma
Old Hand
Old Hand (389 reputation)Old Hand (389 reputation)Old Hand (389 reputation)Old Hand (389 reputation)Old Hand (389 reputation)Old Hand (389 reputation)Old Hand (389 reputation)Old Hand (389 reputation)

Group: General Forum Members
Points: 389 Visits: 185
Patti:

The script has an error....I was using SetMessages as my stored proc for having my custom error messages. You can remove that piece of code from the first proc usp_DropDB and you will be fine or alternatively you can make a change to the usp_ForceDropDb stored procedure and replace the statement in the end:
"EXEC usp_DropDB @DatabaseName"
with
SET @DatabaseName = QUOTENAME(@DatabaseName)
EXEC ('DROP DATABASE ' + @DatabaseName )

Hth,

Rahul




Rahul Sharma
Senior Database Administrator
Manhattan Associates
Atlanta, GA
jonkusnir
jonkusnir
Forum Newbie
Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)

Group: General Forum Members
Points: 1 Visits: 1
Hi, thanks for this one!

Mnd goal is to publish a content database from staging to live, safely, from an admin web page. The wrinkle is that the DB must remain alive on the web during the process ... I plan to modify the DSNs on the fly.

One small point, when I use this in SQL 7 it returns an error "You can't kill your own process."

This error was causing the calling DTS package to fail on this step.

I simply added a clause to the SELECT of spids to exclude "@@SPID" which is the current process.

SELECT spid
FROM master.dbo.sysprocesses
WHERE dbid =
(SELECT dbid FROM master.dbo.sysdatabases
WHERE name = @DatabaseName)
AND spid <> @@SPID
^^^^^^^^^^^^^

It worked fine and once again I appreciate the resource, I don't know much T-SQL ... I'm actually a web guy using Cold Fusion with SQL Server.

- Jon



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