SQL Server Output Clause into a scalar variable

后端 未结 3 712
北海茫月
北海茫月 2020-11-30 07:05

Is there any \"simple\" way to do this or I need to pass by a table variable with the \"OUTPUT ... INTO\" syntax?

DECLARE @someInt int

INSERT INTO MyTable2(         


        
3条回答
  •  盖世英雄少女心
    2020-11-30 07:33

    Over a year later... if what you need is get the auto generated id of a table, you can just

    SELECT @ReportOptionId = SCOPE_IDENTITY()
    

    Otherwise, it seems like you are stuck with using a table.

提交回复
热议问题