Thursday, February 21, 2008

Create Stored Procedure - What Is Stored Procedure Part - II

create a simple table Book, it contain 6 fields(columns) i which rowid in identity column which generated the number in sequence order.
CREATE TABLE BOOK
(
iROWID INT IDENTITY(1,1) PRIMARY KEY,
vBOOKNAME VARCHAR(20),
vAUTHOR VARCHAR(30),
vPUBLICATION VARCHAR(50),
vEDITION VARCHAR(20),
vPRICE NUMERIC(5,2)
)

CreatingProcedure For Inserting Data Into The Table

CREATE PROC PROC_ADD_BOOK
(
//declaration Part
@vBookName VARCHAR(20),
@vAUTHOR VARCHAR(30),
@vPUBLICATION VARCHAR(50),
@vEDITION VARCHAR(20),
@vPRICE NUMERIC(5,2)
)AS
BEGIN
INSERT INTO BOOK(vBOOKNAME,vAUTHOR,vPUBLICATION,vEDITION,vPRICE)
VALUES (@vBookName,@vAUTHOR,@vPUBLICATION,@vEDITION,@vPRICE)
END

Executing The Procedure
EXEC PROC_ADD_BOOK 'XML & ASP.NET','KRIK ALLAN EVANS','PEARSON EDUCATION','2002','555'


No comments:

Creative Commons License
Disclaimers:We have tried hard to provide accurate information, as a user, you agree that you bear sole responsibility for your own decisions to use any programs, documents, source code, tips, articles or any other information provided on this Blog.