August 2, 2012 at 10:41 am
Is there a way to drop a stored procedure without first running USE <database> to change the active connection to the database the procedure is in?
Eg: to drop a table you can do
DROP TABLE MyDatabase..MyTable
but to drop a procedure you have to do USE MyDatabase
DROP PROCEDURE MyProcedure
and I need to be able to do something like DROP PROCEDURE MyDatabase.MyProcedure
I can't just create a new procedure to pass in the database and change the connection inside the procedure, I need to be able to drop the procedure without changing the database connection at all.
August 2, 2012 at 10:52 am
I tried on one of my test boxes, SQL Server 2008 Standard:
Msg 166, Level 15, State 1, Line 1
'DROP PROCEDURE' does not allow specifying the database name as a prefix to the object name.
August 2, 2012 at 10:57 am
how about dynamic SQL?
execute ('use Perfect1012;drop procedure dbo.pr_fake')
works for me.
Lowell
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply