--
ALTER PROCEDURE [dbo].[tb_ADD]
@a int,
@b(20),
AS
BEGIN
--开始事务
begin tran
if exists(select ID from tbwhere a=@a and b=@b )
begin
rollback tran
return -1--该记录已存在.
end
INSERT INTO [tb]( [a],[b] )VALUES(@a,@b )
IF @@error <> 0
BEGIN
rollback tran
return 0--失败
END
else
begin
commit tran
return 1 --成功
end
END