Stored Procedure in MS SQL Server 2005 (Insert)


Store procedure is a collection of pre-defined Transact-SQL is used to perform specific tasks or task. In stored procedures can contain multiple statements and any statements are grouped to a database object.

Now I will explain first about stored procedures in sql server 2005.

General syntax to create a procedure :
CREATE PROC [name of procedure]
AS
BEGIN
     <syntax sql>
END

Example :
CREATE PROC save_user
@name varchar(10),
@pass varchar(20)
AS
 insert into users values (@name,@pass)
END

To execute stored procedure, use :
EXEC [name of procedure] [variablename]

Example :
EXEC save_user 'admin','admin'

Comments