OUTPUT 子句与 scope_Identity() 有什么区别?优点缺点?
举个例子,
create table myTable
(
Id int identity(1,1) primary key clustered,
myData varchar(50) not null
);
create table #myTempTable (i int not null);
insert myTable (myData)
output inserted.Id into #myTempTable
values ('MyData');
select * from #myTempTable