我正在插入 MS SQL Server 2008 中的表(它是来自同一个表的值的副本)并且想要获取插入的输出值。我想获取 select 语句的 id 值(下例中的 t.id), INSERTED.id 工作得很好
create table tmp.tbl_inserted (fromId int, toId int)
INSERT INTO mytable (name)
OUTPUT t.id, INSERTED.id INTO tmp.tbl_inserted
SELECT t.name FROM mytable t
提前致谢