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

Leave Comment