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

📄 spupdateinventory.sql

📁 微软的行业应用解决方案示例
💻 SQL
字号:
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE spUpdateInventory
	@Name VarChar(100),
	@Picture Image,
	@Price Money,
	@InStock Int,
	@DistributionCenter Int,
	@Bin Int,
	@InventoryId Int,
	@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 [Inventory]
	SET 
		[Name] = @Name
		,[Picture] = @Picture
		,[Price] = @Price
		,[InStock] = @InStock
		,[DistributionCenter] = @DistributionCenter
		,[Bin] = @Bin
	FROM Inventory I
	WHERE I.InventoryId = @InventoryId	
	AND	@sync_last_received_anchor >= 
						ISNULL(
								(SELECT CT.SYS_CHANGE_VERSION 
								FROM CHANGETABLE(VERSION Inventory, (InventoryId), (I.InventoryId)) AS CT),
							0)

     SET @sync_row_count = @@ROWCOUNT;
END
GO

⌨️ 快捷键说明

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