Wednesday, 12 November 2014

How to create Code First Insert/Update/Delete Stored Procedures



Creating stored procedure For Insert, Update, Delete, Find (search)

All friend in this article I am explain basic concept of creating store procedure in Sql Server .
Defination
1)In a database management system (DBMS), a stored procedure is a precompiled set of Structured Query Language (SQL) statements that can be shared by a number of programs.
2)Stored procedures must be called or invoked, as they are sets of SQL and programming commands that perform very specific functions. Most major relational database systems (e.g., SQL Server, Oracle, MySQL, Postgres and others) provide support for stored procedures.









<br/>----------------------------------------
Example for creating stored procedure

*) Creating Insert stored procedures for above fields.
create procedure insertdatanew
(@spfirstname varchar(30),@splastname varchar(30),@spemailid varchar(30),@spphonemo bigint,@sploaction varchar(30))
as
begin
insert into registrationdata values (@spfirstname,@splastname,@spemailid,@spphonemo,@sploaction)
end
*) Creating Delete stored procedures for above fields.
create procedure deletedata
@sno int
as
begin
delete * from registrationdata
end

GO
*) Creating Update stored procedures for above fields.


Create procedure gridupdatedata
@spsno int ,@spfirstname varchar(30),@splastname varchar(30),@spemailid varchar(30),@spphoneno varchar(30),@splocation varchar(30)
as
begin
update registrationdata set firstname=@spfirstname,lastname=@splastname,emailid=@spemailid,phoneno=@spphoneno,location=@splocation where sno=@spsno
end
go
*) How Creating select  * from  table stored procedures for above fields.

create procedure [dbo].[deletedata]
@sno int
as
begin
Select * from registrationdata where sno = @sno
end

GO


0 comments:

Post a Comment