我在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
Run Code Online (Sandbox Code Playgroud)
提前致谢