USE [LotteryData]
GO
/****** 对象: StoredProcedure [dbo].[sp_DeleteAward] 脚本日期: 07/06/2010 10:09:03 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: yabin.zhao
-- Create date: 6.22
-- Description: 删除中奖
-- =============================================
ALTER PROCEDURE [dbo].[sp_DeleteAward]
@Status int output,
@issueid varchar(5),
@productid int,
@EngineID int
AS
BEGIN
begin transaction
/*声明变量*/
declare @ErrorMsg varchar(200)
set @Status = 0
/*初始化变量*/
delete from award from AwardGradeDetail award inner join Lotteryorder lo on lo.OrderID=award.AwardOrderID where lo.ProductID=@productid and lo.IssueID=@issueid and lo.EngineID=@EngineID
if @@error<>0
begin
set @ErrorMsg='删除中奖出错'
set @Status=1
goto EXIT_ERROR
end
delete from aod from AwardOrderDetail aod inner join Lotteryorder lo on lo.OrderID=aod.AwardOrderID where lo.ProductID=@productid and lo.IssueID=@issueid and lo.EngineID=@EngineID
if @@error<>0
begin
set @ErrorMsg='删除详细出错'
set @Status=1
goto EXIT_ERROR
end
delete from ao from AwardOrder ao inner join Lotteryorder lo on lo.OrderID=ao.AwardOrderID where lo.ProductID=@productid and lo.IssueID=@issueid and lo.EngineID=@EngineID
if @@error<>0
begin
set @ErrorMsg='删除订单出错'
set @Status=1
goto EXIT_ERROR
end
delete from AwardIssue where IssueID=@issueid and LotteryID = @productid
if @@error<>0
begin
set @ErrorMsg='删除期次出错'
set @Status=1
goto EXIT_ERROR
end
commit transaction
goto EXIT_END
EXIT_ERROR:
rollback transaction
raiserror(@ErrorMsg,16,1)
EXIT_END:
END
================================================================
两个表连接删除