Learn about SQL Server databases, the way SQL Server stored procedures are built, and here's how you can build SQL Server stored procedures to help you.
In Object Explorer, connect to an instance of a database engine, and then expand the instance.
Expand Databases, the database to which the SQL Server stored procedures belong, and programmability.
Right-click Stored procedures, and then click New Stored Procedure.
On the Query menu, click Specify values for template parameters.
In the Specify Values for template Parameters dialog box, the Value column contains the recommended values for the parameters. Accept the values or replace them with the new values, and then click OK.
In the Query Editor, replace the SELECT statement with a procedure statement.
To test the syntax, on the Query menu, click Analyze.
To create a SQL Server stored procedure, on the Query menu, click Execute.
To save your script, on the File menu, click Save. Accept the file name or replace it with a new name, and then click Save.