1
Declare @myTrace TABLE (
srcId int,
destId int);
INSERT INTO Destination (Refer, OtherData)
OUTPUT s.id, INSERTED.id INTO @myTrace --can't use s.id ??
SELECT Refer, OtherData
FROM MySource s
WHERE somecondition = 1;
似乎SQL Server不接受來自MySource的字段,如果它們沒有插入到目標表中。我對嗎 ?任何解決方法? (我正在使用2008 R2)不能在INSERT ... OUTPUT中使用非INSERTED.fields?
[使用merge..output獲取source.id和target.id之間的映射]的可能重複(http://stackoverflow.com/questions/5365629/using-merge-output-to-get-mapping-between -source-id-and-target-id) –