Template for Adding stuff to SQL Server

Here's a template for adding objects to a database when you're not sure if the existing one is there or not, and you just want to dump it and recreate it.


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

Create Proc [dbo].[myStoredProc]
@myId int
AS
select foo...
...
GO

Comments

Popular Posts