-1
我的SQL语句是这样如何关闭,如果情况SQL
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[Bid_Create]
@BidNo nchar(12)
,@BidType int
,@ClientId int
,@BidDate date
,@EmailNotificationStatus int
,@BidStatus int,
@BidAmount int
AS
DECLARE @highestBid int;
BEGIN
Begin Try
Begin Transaction
SET NOCOUNT ON;
set @highestBid = (SELECT Max(wf_bid.BidAmount) as HighestBitAmount from wf_bid where wf_bid.ProductId = '1')
IF @[email protected]
UPDATE wf_bid SET [email protected] ,[email protected] ,[email protected] , [email protected],[email protected]
WHERE Id= (SELECT TOP 1 id
FROM [wf_bid]
WHERE BidAmount = (Select Max(BidAmount) FROM [wf_bid] WHERE ProductId=101 and ClientId=101))
INSERT INTO wf_bid
(BidType,ClientId,BidDate,EmailNotificationStatus,BidStatus)
VALUES
(@BidType,@ClientId,@BidDate ,@EmailNotificationStatus ,@BidStatus)
Commit Transaction
End Try
Begin Catch
Rollback Transaction
End Catch
END
我的问题是,如果情况得到第一update
语句本身后关闭。我希望它在只有第二个Insert语句也被执行后关闭。我需要在查询中做出什么改变才能实现这一点?
使用'BEGIN'和'END' – anon
你应该包括一个BEGIN END对中的ELSE部分(开始更新之前,END行;你的后插入) – nabuchodonossor
@LovepreetSingh这是关于MySQL,而不是SQL Server。 – TZHX