MSSQLTips.com - your daily source for SQL Server tips

Google
 
Web mssqltips.com

ESSENTIALS: Home | Tips | Search | Categories | Top 10 | Products | Authors | Blogs | Forums | Webcasts | Advertise | About
how to create stored procedure -

in Search

how to create stored procedure

Last post 06-09-2008 9:24 AM by mdubey. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 04-29-2008 3:12 AM

    how to create stored procedure

     

  • 05-01-2008 11:35 PM In reply to

    • tosc
    • Top 25 Contributor
    • Joined on 03-12-2008
    • Germany
    • Posts 6

    Re: how to create stored procedure

    Hi ramu143,

    plz take a look at BOL: CREATE PROCEDURE

    CU
    tosc

    - http://www.insidesql.org
    - http://www.insidesql.org/blogs/tosc
    Filed under:
  • 05-15-2008 7:54 AM In reply to

    Re: how to create stored procedure

    Hi ramu143

    I Give the syntax for the creating Procedures

    Create Proc Proc_Name (Statements Like Condition)

  • 05-16-2008 6:34 AM In reply to

    Re: how to create stored procedure

    Take a look at this tip:

    http://www.mssqltips.com/tip.asp?tip=1495

     

  • 05-29-2008 10:56 PM In reply to

    • karan
    • Top 500 Contributor
    • Joined on 05-30-2008
    • Posts 1

    Re: how to create stored procedure

    create proc (name of proc)

    @parameter  datatype( which pass in runtime)

    we can pass three type para (input, output, (input,output)

    as

    begin

     

    statement .....

     

    end 

  • 06-09-2008 9:24 AM In reply to

    • mdubey
    • Top 10 Contributor
    • Joined on 06-09-2008
    • Posts 8

    Re: how to create stored procedure

    Hi Ramu,

     

    This is the syn. for  creating stored proc from t-SQl with every parameter.

     

    CREATE PROCEDURE

    Create a stored procedure.

    Syntax
          CREATE PROC[EDURE] [schema.]procedure  
             [ { @parameter [schema.]data_type } 
                 [VARYING ] [ = default ] [ OUT[PUT] ]
             ] [ ,...n ] 
             [WITH Option [,...n ]]
          AS { sql_statement [;][ ...n ] | EXTERNAL NAME assembly.class.method }
          [;]
    
       Options: 
          ENCRYPTION
          RECOMPILE
          EXECUTE_AS_Clause
          [FOR REPLICATION]
    
       sql_statement 
          [BEGIN] statements [END]
    
    Key
       @parameter   A local parameter in the procedure.
       VARYING      The result set contents may vary: a cursor parameter dynamically constructed by the procedure. 
       default      A default value for the parameter. A constant or NULL
       OUTPUT       Indicates an output parameter.
       RECOMPILE    Do not cache a plan for this procedure - compile at run time.
       ENCRYPTION   Encrypt the text of the CREATE PROCEDURE statement.
       FOR REPLICATION Execute only during replication.
       EXTERNAL NAME   Reference to a method of a .NET Framework assembly.
    

    Example

    CREATE PROCEDURE Sales.GetPartsOfType
    @PartCode nvarchar(50)
    AS
    SELECT PartCode, Description
    FROM Sales.parts
    WHERE PartCode = @PartCode;
    GO
    Manoj Dubey

    MCP, MCTS (GDBA, EDA) Admin
Page 1 of 1 (6 items)