demonfox (3/6/2013)
the explanations saysThe CREATE PROCEDURE statement cannot be combined with other Transact-SQL statements in a single batch. The same rule applies to Functions as well, but this is not noted in MSDN.
simplifying it a little bit .. "Create Procedure" can't be inside a BEGIN..END statement..
But Drop Procedure can be
so this will work..
IF OBJECT_ID('dbo.uspUSP') IS not NULL
drop PROCEDURE dbo.uspUSP
GO
so, as lokesh says .. Create a proc using dynamic query 😀 , With IF condition 😛
+1
Drop statement can be also be used 🙂
~ Lokesh Vij
Link to my Blog Post --> www.SQLPathy.com[/url]
Follow me @Twitter