Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Checking If A Proc Exists
Message
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Miscellaneous
Thread ID:
01245040
Message ID:
01245089
Views:
20
The 'DROP PROCEDURE statement dosen't support local variables in place of procedure name. You'll have to use dynamic SQL.
EXEC('DROP PROCEDURE ' + @SProcName)
>Getting an error:
>
>
>CREATE PROCEDURE sp_ProcExists
>	@SProcName nvarchar(100
>AS
>
>  IF EXISTS (SELECT *
>               FROM dbo.sysobjects
>	       WHERE id = object_id(@SProcName) AND
>	       OBJECTPROPERTY(id, N'IsProcedure') = 1)
>
>     DROP PROCEDURE @SProcName                 <=========== Errors here
>
>
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform