Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/svg/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql server 输出子句sql上的筛选器_Sql Server_Tsql - Fatal编程技术网

Sql server 输出子句sql上的筛选器

Sql server 输出子句sql上的筛选器,sql-server,tsql,Sql Server,Tsql,我试图在t-sql中的输出子句上使用筛选器 我想做的是这样的: Insert into tbl_1(col1,col2) Output Inserted.col1 into #tbl_temp **where col1 > 0** select col3, col4 from tbl_2 出于性能原因,我不想使用两个insert语句。我不知道您可以这样做。把一个更新动作当作一个附属动作,感觉太脏了。@Damien_不信者–本页的示例K就是这样做的@Damien,@Carovei–它在这

我试图在t-sql中的输出子句上使用筛选器

我想做的是这样的:

Insert into tbl_1(col1,col2)
Output Inserted.col1 into #tbl_temp 
**where col1 > 0**
select col3, col4
from tbl_2

出于性能原因,我不想使用两个insert语句。

我不知道您可以这样做。把一个更新动作当作一个附属动作,感觉太脏了。@Damien_不信者–本页的示例
K
就是这样做的@Damien,@Carovei–它在这里的
下记录。我今天做了一些测试,这种形式的插入比使用2个插入的情况更糟糕(从执行时间上讲)。也许在应该使用它的时候它有一些特殊情况,但是现在我将使用2个insert语句方法:D
insert into #tbl_temp
select col1
from
  (
    insert into tbl_1(col1,col2) 
    output Inserted.col1
    select col3, col4 
    from tbl_2
  ) as T
where T.col1 > 0