2009/09/14

SQL - create stored procedure if not exists

IF NOT EXISTS(Select * from sysobjects where name = 'usp_UserSproc')
BEGIN
EXEC dbo.sp_executesql @statement = N'
CREATE PROCEDURE usp_UserSproc
(
@ID int = NULL --nullable input
)
AS
BEGIN
-- BLAH BLAH BLAH
END';
END

No comments:

Post a Comment