SQL is coding language of database development and administration. After creating database and filing it up with information, data saved inside can be accessed and manipulated with statements written in SQL. Most times a database administrator will find using same SQL statement again and again. These often used statements can be written once and placed in a saved process, to be called quickly and easily when required.

Making own Stored Procedure

• Write down a SQL statement. SQL enables accessing and manipulate data in a database with plain instructions. Like, an INSERT statement enables adding new data, an UPDATE statement enables editing data and a SELECT statement enables retrieving data. Determine the Stored procedures function, and write down a SQL statement to produce preferred result. Verify statement in command window to make sure outcome is expect result, then save statement in notepad.

• Open Stored Procedure wizard. Every database platform is a bit hard, but each database uses SQL will have interface for adding stored procedures.

• Add comments section to stored procedure. Comments are good coding practice as they add information about coding intent and offer a place to log modifications to code made over time. Inside comments section add name of procedure, description of procedure, date of creation, author name and section for modification. Comments must begin with /* and end with */.

• Make stored procedure. SQL needs following words for creation of a stored procedure.

CREATE PROCEDURE usp_storedprocedurename
AS

prefix usp_ is convention used in SQL to recognize stored procedure names. It's unnecessary, but it is a nice idea. Name of stored procedure can be anything, but it is a nice idea to give it a meaningful name describing procedure. The below line make command will have only word "AS". This command tells server to assign code that follows to stored procedure named above.

• Add SQL statement. Copy and paste statement stored in notepad in space under "AS" command line. Store stored procedure. To run stored procedure, use exec command in command window as follows.

exec usp_storedprocedurename