You are on page 1of 3

1)what is storedprocedure?

Stored Procedure :-

stored procedure is a precompiler.A stored procedure is a group of sql statements that has been
created and stored in

the database. Stored procedure will accept input parameters,out put parameters so that a single
procedure can be used

over the network by several clients using different input data. Stored procedure will reduce
network traffic and increase

the performance. If we modify stored procedure all the clients will get the updated stored
procedure

advantages:

a) Stored procedure allows modular programming.

You can create the procedure once, store it in the database, and call it any number of times
in your program.

b) Stored Procedure allows faster execution.

c) Stored Procedure can reduce network traffic.

d) Stored procedures provide better security to your data

Disadvantages:

Writing and maintaining stored procedures requires more specialized skills.


There are no debuggers available for stored procedures

Stored procedure language may differ from one database system to another.

Poor exception handling

* Tightly coupled to the database system

* Not possible to use objects

* Sometimes it is hard to understand the logic written in dynamic SQL

create stored procedure:

create procedure procedurename

input parameters ,

OUTPUT PARAMETERS

AS

BEGIN

SQL QUERY

END

SELECT COMMAND:

CREATE PROC SP_SELECT

AS

BEGIN

SELECT * FROM ASHA

END
INSERT COMMAND:

CTRATE PROC SP_INSERT

@STUDENTID INT,

@STUDENTNAME VARCHAR(50),

@STUDENTADDRESS VARCHAR(50)

AS

BEGIN

INSERT INTO ASHA (STUDENTID,STUDENTNAME,STUDENTADDRESS) VALUES


(@STUDENTID,@STUDENTNAME,@STUDENTADDRESS)

END

update command:

create proc sp_update

@studentid int,

@studentname varchar(50),

@studentaddress varchar(20)

as

begin

update asha set studentname=@studentname,studentaddress=@studentaddress where


studentid=@studentid

endn

You might also like