⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 spupdateorder.sql

📁 微软的行业应用解决方案示例
💻 SQL
字号:
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE spUpdateOrder
    @OrderId UniqueIdentifier,
    @CustomerId Int,
    @DeliveryDate DateTime,
    @OrderState Int,
    @Signature VarBinary,
    @sync_last_received_anchor Int,
    @sync_row_count Int Output
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;
	
	--update only if last cyns received is greater than or equal the row's version
	UPDATE [HardwareDistributor].[dbo].[Orders]
       SET [CustomerId] = @CustomerId
          ,[DeliveryDate] = @DeliveryDate
          ,[OrderState] = @OrderState
          ,[Signature] = @Signature
     FROM Orders AS O
     WHERE 
			O.[OrderId] = @OrderId
     AND	@sync_last_received_anchor >= 
						ISNULL(
								(SELECT CT.SYS_CHANGE_VERSION 
								FROM CHANGETABLE(VERSION Orders, (OrderId), (O.OrderId)) AS CT),
							0)

     SET @sync_row_count = @@ROWCOUNT;
END
GO

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -