我有这个代码,我正在尝试通过一个变量设置身份种子
DECLARE @iKeyX INT
SELECT @iKeyX = MAX(KeyX) FROM Temporales..tmp_Orders
IF (@iKeyX = NULL)
SET @iKeyX = 1
ELSE
SET @iKeyX = @iKeyX + 1
IF OBJECT_ID('tempdb..#tmp_Orders','U') IS NOT NULL
DROP TABLE #tmp_Orders
SELECT IDENTITY(INT, @iKeyX, 1) AS KeyX,
0 AS Valido,
OrderNumber,
OrderType,
Code,
Size,
INTO #tmp_Orders
FROM TableWithData
为什么 SQL 一直告诉我“'@ iKeyX' 附近的语法不正确”?