100% found this document useful (1 vote)
54 views

Using Stored Procedures With ASP

Sprocs are generally an ordered series of Transact-sql statements. They allow for variables and parameters, as well as selection and looping constructs. Advantages over simply sending individual statements to the server include: 1. Referred to using short names rather than a long string of text. 2. Pre-optimized and precompiled, so they save an incremental amount of time.

Uploaded by

api-3742776
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
54 views

Using Stored Procedures With ASP

Sprocs are generally an ordered series of Transact-sql statements. They allow for variables and parameters, as well as selection and looping constructs. Advantages over simply sending individual statements to the server include: 1. Referred to using short names rather than a long string of text. 2. Pre-optimized and precompiled, so they save an incremental amount of time.

Uploaded by

api-3742776
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 3

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.

Advantages over simply sending individual statements to the server include:

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 :

@parameter_name [AS] datatype [= default|NULL] [VARYING] [OUTPUT|OUT]

Let's now create a stored procedure named "Submitrecord".

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.

You might also like