Using Stored Procedures With ASP
Using Stored Procedures With ASP
NET
This article helps you to create a stored procedure on SQL Server and tells you how to use them in your asp.net applications.
Introduction
Stored procedures (sprocs) are generally an ordered series of Transact-SQL statements bundled into a
single logical unit. They allow for variables and parameters, as well as selection and looping constructs.
A key point is that sprocs are stored in the database rather than in a separate file.
1. Referred to using short names rather than a long string of text; therefore, less network traffiic is
required to run the code within the sproc.
2. Pre-optimized and precompiled, so they save an incremental amount of time with each sproc
call/execution.
3. Encapsulate a process for added security or to simply hide the complexity of the database.
4. Can be called from other sprocs, making them reusable and reducing code size.
Parameterization
A stored procedure gives us some procedural capability, and also gives us a performance boost by
using mainly two types of parameters:
• Input parameters
• Output parameters
From outside the sproc, parameters can be passed in either by position or reference.
Declaring Parameters
1. The name
2. The datatype
3. The default value
4. The direction
The syntax is :
First open Microsoft SQL Server -> Enterprise Manager, then navigate to the database in which you
want to create the stored procedure and select New Stored Procedure.