0% found this document useful (0 votes)
24 views2 pages

Executing Store Procedure (SP) in ASP: An Example Is

A stored procedure is a group of pre-compiled Transact-SQL statements that performs a specific task. Stored procedures allow developers to execute repetitive SQL statements by calling the stored procedure instead of rewriting the SQL code. Stored procedures reduce bandwidth and execution time compared to separate SQL statements. They also allow businesses to store their logic in the database independent of the user interface, making it easier to migrate systems from one technology to another.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views2 pages

Executing Store Procedure (SP) in ASP: An Example Is

A stored procedure is a group of pre-compiled Transact-SQL statements that performs a specific task. Stored procedures allow developers to execute repetitive SQL statements by calling the stored procedure instead of rewriting the SQL code. Stored procedures reduce bandwidth and execution time compared to separate SQL statements. They also allow businesses to store their logic in the database independent of the user interface, making it easier to migrate systems from one technology to another.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Executing Store Procedure (SP) in ASP

A stored procedure is a group of Transact-SQL statements compiled into a


single execution plan.
In a layman language a stored procedure is an already written SQL
statement that is saved in the database. If we find ourselves using the same
query over and over again, it would make sense to put it into a stored
procedure. When we put this SQL statement in a stored procedure, we can
then run the stored procedure from the database's command environment ,
using the exec command.
An example is:
CREATE PROCEDURE NameOfStoreProcedure
AS
SELECT FirstName, LastName FROM TableName;
GO
EXEC NameOfStoreProcedure
The name of the stored procedure is "NameOfStoreProcedure ", and "exec"
tells SQL Server to execute the code in the stored procedure.
There are two main advantages of using store procedure in our program

Because stored procedures are stored within the DBMS, bandwidth and
execution time are reduced. This is because a single stored procedure
can execute a complex set of SQL statements.

With Store procedure we will store our entire business login inside the
database itself. So if we plan to migrate from one technology to
another say from classic ASP to .NET then we only need to change the
user interface reset of the business logic remain same.
set con = Server.CreateObject("ADODB.Connection")
con.Open strConnect
Set Comm = Server.CreateObject("ADODB.Command")
comm.ActiveConnection = con
comm.CommandText = "sqlstoredprocedurename"
comm.CommandType = adCmdStoredProc
comm.Parameters.Append comm.CreateParameter("ID" ,
adVarchar,adParamInput, 50, id)
comm.Parameters.Append comm.CreateParameter("PRODUCT", adVarchar,

adParamInput,50, producttype )
comm.Parameters.Append comm.CreateParameter("ACCOUNT", adVarchar,
adParamInput,100, "" )
comm.Parameters.Append comm.CreateParameter("O_Errors", adVarchar,
adParamOutput,50) 'output parameters
comm.Execute

You might also like