Stored Procedures
Stored Procedures
Stored Procedures
com
STORED PROCEDURES
A stored procedure is a group of Transact-SQL statements compiled into a single
execution plan.
• Accept input parameters and return multiple values in the form of output
parameters to the calling procedure or batch.
You can use the Transact-SQL EXECUTE statement to run a stored procedure. Stored
procedures are different from functions in that they do not return values in place of
their names and they cannot be used directly in an expression.
The benefits of using stored procedures in SQL Server rather than Transact-SQL
programs stored locally on client computers are:
These procedures will be created in the user database. The user who creates
the procedure will become the owner for that procedure.
www.gcreddy.com 1
www.gcreddy.com
a temporary stored procedure can be created and compiled on the first execution,
then execute the precompiled plan multiple times. The temporary stored procedures
can be local or global.
They are legacy feature of SQL Server. Their functionality in T-SQL is limited
to executing a stored procedure on a remote SQL Server installation. The distributed
queries in SQL Server support this ability along with the ability to access tables on
linked OLEDB data sources directly from local T_SQL statements.
These are dynamic link libraries (DLLs) that SQL Server can dynamically load
and execute. These procedures run directly in the address space of SQL Server and
are programmed using the SQL Server Open Data Services API. They are identified
by the xp_prefix.
Syntax:
www.gcreddy.com 2