USE [LotteryData]
GO
/****** 对象: StoredProcedure [dbo].[sp_ExecuteNoWining] 脚本日期: 07/06/2010 10:05:58 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: yb.zhao
-- Create date: 6.12
-- Description: 未中奖
-- =============================================
ALTER PROCEDURE [dbo].[sp_ExecuteNoWining]
@Status int output,
@issueid varchar(5),
@productid int,
@EngineID int
AS
BEGIN
begin transaction
declare @ErrorMsg varchar(500)
declare @CurrentDate datetime
set @CurrentDate=getdate()
set @Status = 0
/*把详细表里的status为8的数据 订单表里更新为3*/
update lo set LotteryStatus = 3, WorkflowStatus=1, ModifiedDate=@CurrentDate from lotteryorder lo
inner join
(select distinct loy.OrderID from lotteryorder loy inner join lotteryorderdetail lod
with(nolock) on loy.OrderID = lod.OrderID
where loy.EngineID = @EngineID and loy.ProductID = @ProductID
and loy.IssueID = @IssueID and lod.[Status] = 8) A on lo.OrderID = A.OrderID
if @@error<>0
begin
set @ErrorMsg='更新订单时出错'
set @Status=1
goto EXIT_ERROR
end
update lod set status=3 from lotteryorderdetail lod
inner join
(select lodt.* from lotteryorderdetail lodt inner join lotteryorder lo
with(nolock) on lo.OrderID=lodt.OrderID
where lo.EngineID = @EngineID and lo.ProductID = @ProductID
and lo.IssueID = @IssueID and lodt.Status = 8) B on lod.OrderDetailID=B.OrderDetailID
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
=========================================================================
1.存储过程的格式
2.update语句