本文介绍了SQL Server 输出子句转换为标量变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否有任何简单"的方法可以做到这一点,或者我需要使用OUTPUT ... INTO"语法传递一个表变量?
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(AIntColumn)
OUTPUT @SomeInt = Inserted.AIntColumn
VALUES(12)
推荐答案
你需要一个表变量,它可以这么简单.
You need a table variable and it can be this simple.
declare @ID table (ID int)
insert into MyTable2(ID)
output inserted.ID into @ID
values (1)
这篇关于SQL Server 输出子句转换为标量变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!