首页 > 代码库 > 存储过程删除举例

存储过程删除举例

USE [NLISSST]
GO
/****** Object: StoredProcedure [SST].[sp_ArbitrationDeleteByID] Script Date: 05/08/2014 10:26:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Author,,高明胜>
-- Create date: <Create Date,,2014-3-11>
-- Description: <Description,,根据ID删除>
-- =============================================
ALTER PROCEDURE [SST].[sp_ArbitrationDeleteByID]
-- Add the parameters for the stored procedure here
@Result int output,--输出结果参数
@ArbitrationID bigint
as
Set @Result=0
Declare @Error int
Set @Error=0
If Exists(Select * From SST.tbArbitration Where ArbitrationID=@ArbitrationID)--存在该项
Begin
if Exists(Select * From SST.tbArbitration Where ArbitrationID=@ArbitrationID and ArbitrationStatus=1)
Begin
Set @Result=2--该数据已仲裁,不允许删除!
End
else
begin
Delete From SST.tbArbitration Where ArbitrationID=@ArbitrationID--删除指定编号的仲裁信息
Set @Error=@Error+@@Error--累加错误数量
if(@Error=0)
Begin
Set @Result=1--成功
End
Else
Begin
Set @Result=0--失败
End
end
End
Else
Begin
Set @Result= -1--没有该数据记录
End