我有以下声明:
DECLARE @Nr_Karton int;
SELECT @Nr_Karton = ISNULL(MAX(Nr), 1000) FROM W_Karton;
SET @Nr_Karton = @Nr_Karton + 1;
INSERT INTO W_Karton (Container_ID, Nr, Beschrieb, CreationDate, Location)
VALUES ('1', @Nr_Karton, '', getDate(), 'Bösingen');
但我得到了错误:
[SQL] 从 W_Karton 中选择 @Nr_Karton = ISNULL(MAX(Nr), 1000)
[Err] 42000 - [SQL Server]必须声明标量变量“@Nr_Karton”。
如何摆脱错误?