Starting with SQL Strore Procedure (Viewed - 1865 times)



1.    In Object Explorer, Create a DataBase MyDataBase and then expand that instance.
2.    Now go to Programmiblity , you can see a folder named as Store Procedure
3.    Right-click Stored Procedures, and then click New Stored Procedure.
4.    Now, you will a Query edit the name of Storeprocedure. Like here

    CREATE PROCEDURE userInfoProcedure
   
5.    Now below the comment
    -- Add the parameters for the stored procedure here
    Edit the parameters and add your own parameters. Like here
    @FirstName varchar,
        @LastName varchar

6.    Now edit the select statement and write
    SELECT FirstName , LastName,Age from UserInfo where FirstName=@FirstName and LastName=@FirstName


7.    The final storeprocedure will look like

    Create PROCEDURE userInfoProcedure
        -- Add the parameters for the stored procedure here
        @FirstName varchar,
        @LastName varchar
    AS
    BEGIN
       
        SET NOCOUNT ON;

        -- Insert statements for procedure here
        SELECT FirstName  , LastName,Age from UserInfo where FirstName=@FirstName
        and LastName=@FirstName
    END
    GO

Note: If you want to edit store-procedure than instead of create Keyword use Alter Keyword.



Post Article  Post Code 
  Post Tip    Start Forum
 
Quick note for developers
Google+
Follow