September 9, 2013 at 5:17 am
Hi all!
I want to check about a sored procedure does exist before i Create/alter it.
How to?
When it's about a table, SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = '[TABLE_NAME]' just does the trick - there must be something very similar.
Best regards
Edvard Korsbæk
September 9, 2013 at 5:32 am
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[myproc]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[myproc]
GO
September 9, 2013 at 5:39 am
Thanks!
September 11, 2013 at 5:22 am
adb2303 (9/9/2013)
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[myproc]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[myproc]
GO
+1 🙂
_______________________________________________________________
To get quick answer follow this link:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
September 11, 2013 at 5:55 am
Here's another way.
IF OBJECT_ID('ProcedureName', 'P') is not null drop procedure ProcedureName;
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply