How to check stored procedure | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

How to check stored procedure

hi, I wanna to check the strored procedure.
Is it already exist
if yes then drop
else
create.



IF EXISTS(SELECT name FROM sysobjects WHERE name = ‘your_sp’ AND type = ‘P’)
DROP PROCEDURE your_sp
GO
CREATE PROCUEDURE

KH
SQL is a declarative language. So, in most cases, such as this, you can translate your requirement 1:1 to SQL. [<img src=’/community/emoticons/emotion-1.gif’ alt=’:)‘ />]<br /><br />–<br />Frank Kalis<br />Moderator<br />Microsoft SQL Server MVP<br />Webmaster:<a target="_blank" href=http://www.insidesql.de>http://www.insidesql.de</a>
quote:Originally posted by khtan IF EXISTS(SELECT name FROM sysobjects WHERE name = ‘your_sp’ AND type = ‘P’)
DROP PROCEDURE your_sp
GO
CREATE PROCUEDURE

KH
Thanks . i will use this…
Could send the example
1) stored procedure with output parameters..
2) How to retrieve and execute the stored procedure

Read about Output parameter in sql server help file Madhivanan Failing to plan is Planning to fail
2) To retrieve simply call the SP by using the same database, as mentioned books online will have all relevant code examples for you to understand. Satya SKJ
Microsoft SQL Server MVP
Writer, Contributing Editor & Moderator
http://www.SQL-Server-Performance.Com
This posting is provided AS IS with no rights for the sake of knowledge sharing. Knowledge is of two kinds. We know a subject ourselves or we know where we can find information on it.
Thanks..

IF object_id(‘procname’) IS NOT NULL
DROP PROCEDURE procname
Go
CREATE PROCEDURE procname Thanks,
Ram "It is easy to write code for a spec and walk in water, provided, both are freezed…"
quote:Originally posted by ramkumar.mu IF object_id(‘procname’) IS NOT NULL
DROP PROCEDURE procname
Go
CREATE PROCEDURE procname Thanks,
Ram "It is easy to write code for a spec and walk in water, provided, both are freezed…"
If you pass tablename in place of procname, it wont work as expected Madhivanan Failing to plan is Planning to fail
]]>