Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to work on Stored Procedure in SQL

    • 0
    • 2
    • 2
    • 1
    • 0
    • 0
    • 0
    • 0
    • 328
    Comment on it

    Store Procedure:-- These are set of SQL Statements which are grouped in such a way that they execute to do a certain task and make processing of our application fast.

    Advantages:- They are stored in precompiled format and therefore are fast.

    Only parameters are passed to the backend instead of query therefore less network utilization.

    Besides all these the most important advantage of using Stored Procedure which I found is whenever I needs to make any changes in my application then I only have to open the specific procedure do the changes and then saves that one. No need of going into the code again.

    How to create :-

    CREATE Procedure GetOrders
    (
    @UserID INT
    -- Parameter Declaration
    )

    AS

    BEGIN

    select Orders.UserID, Orders.OrderID,Orders.FirstName,Orders.LastName,Orders.OrderStatus FROM Orders WHERE UserID = @UserID

    END

    Note:- Write this and press F5

    How to modify:-

    ALTER Procedure GetOrders
    (
    @UserID INT
    )
    AS
    BEGIN

    select Orders.UserID, Orders.OrderID,Orders.FirstName,Orders.LastName,Orders.OrderStatus FROM Orders WHERE UserID = @UserID

    END

    Note:- Write this and press F5

    How to Open:-

    sp_helptext GetOrders

    Note:- Its is always in good practice to open a procedure in a "Results to Text" Format

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: