DECLARE @id int
INSERT INTO MyTable(name)
OUTPUT @id = Inserted.id
VALUES('XYZ')
我正如上所述。怎么可能?
答案 0 :(得分:73)
使用表变量获取id
DECLARE @id int
DECLARE @table table (id int)
INSERT INTO MyTable(name)
OUTPUT inserted.id into @table
VALUES('XYZ')
SELECT @id = id from @table
答案 1 :(得分:0)