我想从table1和table2下面的两个不同的表中动态地在临时表@temp中插入数据
表格1:
表2:
Declare @temp table ( Pays nvarchar (300), Factory nvarchar (300), Count bigint)
我试过这个命令,但我有一条错误消息: Subquery returned more than 1 value.
Insert into @temp select (select pays from table1),(select factory,count from table 2 where @Pays=’yes’)
结果如下表 @temp
:
谢谢你的帮助 .
4 回答
您希望join (documentation here)运行单个select语句 .
您可能还想阅读this,因为表变量(@table)和临时表(#table)之间存在重要区别
首先,如果必须,不要使用像Count作为属性的关键字,然后像这样使用 - > [Count]
首先,如果必须,不要使用像Count作为属性的关键字,然后像这样使用 - > [Count]
我不太确定你想要实现什么,但似乎你的table2中的数据需要不显示才能将table1和table2连接到另一个 . 以下就是这样做的 .