SQL Server Performance

How to check stored procedure

Discussion in 'Getting Started' started by ajaySharma, May 20, 2007.

  1. ajaySharma New Member

    hi,

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

  2. khtan New Member


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




    KH
  3. FrankKalis Moderator

    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>
  4. ajaySharma New Member

    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
  5. Madhivanan Moderator

    Read about Output parameter in sql server help file

    Madhivanan

    Failing to plan is Planning to fail
  6. satya Moderator

    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.
  7. ajaySharma New Member

  8. ramkumar.mu New Member

    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..."
  9. Madhivanan Moderator

    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

Share This Page