BEGIN
SET NOCOUNT on;
If @_mode not in (' A ', ' M ', ' D ')
Begin
RAISERROR (' parameter Error! ', 16, 3);
Return
End
declare @rowcount int, @error int;
If @_mode= ' A '
Begin
Insert into Szdxinfo (id,bh,[name],nation) Select
@Id, @Bh, @Name,
@Nation;
If @ @error <>0 return;
End
If @_mode= ' M '
Begin
Update Szdxinfo set [Name][email protected],
[Email protected]
where [email protected];
Select @[email protected] @error, @[email protected] @rowcount;
If @error <>0 return;
If @rowcount <>1
Begin
RAISERROR (' No record changed! ', 16, 3)
Return
End
End
If @_mode= ' D '
Begin
Delete Szdxinfo where [email protected];
select @[email protected] @error, @[email protected] @rowcount;
If @error <>0 return;
If @rowcount <>1
Begin
RAISERROR (' No record deleted! ', 16, 3)
Return
End
End
INSERT into Actionlog ([Date],[userid],computerid,
Tablename,[action]) Select
GETDATE (), @_userid,
@_computerid,
' Szdxinfo ', @_mode;
/*
exec update_szdxinfo @id = ' 11 ',
@Name = ' Liu xxx ',
@Nation = ' Han ',
@_mode = ' A ',
@_userid=1,
@_computerid=1
SELECT * FROM Szdxinfo
*/
END
SQL Server stored procedures, common formats