Home > DeveloperSection > Blogs > Store Procedure is used to Insert and Update Data

Store Procedure is used to Insert and Update Data


C# C# 
Ratings:
0 Comment(s)
 1833  View(s)
Rate this:
Create proc [dbo].[sp_tbStudentInsertUpdate]
(

 @iStudentID_PK int,
 @sStudentName varchar(50),
 @sClass varchar(50),
 @sTrade varchar(50),
 @sAddress varchar(50),
 @iFee int
)
as
if exists(select * from tbStudent where iStudentID_PK=@iStudentID_PK)
begin
update tbStudent set  sStudentName=@sStudentName, sClass=@sClass, sTrade=@sTrade, sAddress=@sAddress, iFee=@iFee where iStudentID_PK=@iStudentID_PK
return 1
end
else
begin
insert into tbStudent( sStudentName, sClass, sTrade, sAddress, iFee)values
( @sStudentName, @sClass, @sTrade, @sAddress, @iFee)
return 0
end

Don't want to miss updates? Please click the below button!

Follow MindStick