Generating 'if exists....' script for stored procedures in SQL Server 2005

  • Hi,

    How do I make SQL Server 2005 generate the following script for my stored procedure which used to happen automatically while creating a stored procedure in SQL Server 2000 -

    ======================

    if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Proc_mySP]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)

    drop procedure [dbo].[Proc_mySP]

    GO

    ======================

    Also, whether at all it is a good practice to have this script in every stored procedure ?

    -Sri

  • There is a option to generate scripts. Rightclick on the db\Tasks\GenerateScripts. On the "choose script options" page can say "True" to "Include IF NOT Exists."

    "Keep Trying"

  • Thanks for that quick reply Chirag. It helped.

  • glad i cud help...

    "Keep Trying"

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply