faqts : Computers : Databases : Microsoft SQL Server

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

2 of 2 people (100%) answered Yes
Recently 2 of 2 people (100%) answered Yes

Entry

Database: SQL: Create: How to delete existing stored procedure in Microsoft SQL server, using SQL?

Dec 31st, 2003 18:47
Knud van Eeden,


----------------------------------------------------------------------
--- Knud van Eeden --- 01 January 2004 - 03:39 am --------------------
Database: SQL: Create: How to delete existing stored procedure in 
Microsoft SQL server, using SQL?
---
Use the following SQL commands:
 IF EXISTS ( SELECT name FROM sysobjects
  WHERE name = '<your stored procedure name>' AND type = 'P')
 DROP PROCEDURE <your stored procedure name>
---
e.g.
So all together:
 USE Northwind
 GO
 IF EXISTS ( SELECT name FROM sysobjects
  WHERE name = 'mystoredprocedurename1' AND type = 'P')
 DROP PROCEDURE mystoredprocedurename1
 GO
 CREATE PROC mystoredprocedurename1
  @parametername1 NVARCHAR( 255 )
 AS
  SELECT * FROM Employees WHERE Firstname LIKE @parametername1
 GO
 EXEC mystoredprocedurename1
  @parametername1 = '%a%'
---
---
Internet: see also:
---
Database: SQL: Query: Stored procedure: Can you give an overview of a 
stored procedure?
http://www.faqts.com/knowledge_base/view.phtml/aid/27892/fid/147
----------------------------------------------------------------------