[英]How to Insert Into Table Values combining arguments and temp table?
I have INSERT statement where I have to use one of my argument values and values from my temporary table. 我有INSERT语句,在这里我必须使用参数值之一和临时表中的值。 I'm using SQL Server 2008. I haven't worked with temp tables before so I'm not sure if and how I can combine argument values and temp table since arguments have to be placed inside of the VALUES() and temp table values are pulled using SELECT. 我使用的是SQL Server2008。之前我没有使用过临时表,所以我不确定是否以及如何组合参数值和临时表,因为参数必须放在VALUES()和临时表值的内部使用SELECT拉。 Here is my code: 这是我的代码:
INSERT INTO myTbl (col1, col2, col3, col4, col5, col6)
//col1 should use #arguments.myVal#
SELECT @col2,@col3,@col4,@col5,@col6
FROM #myTemp
Is there any way to combine values from two different sources into insert statement? 有什么方法可以将来自两个不同来源的值组合到insert语句中?
hope this what you are looking for. 希望这是您想要的。
Declare @Param1 int = 20
INSERT INTO myTbl (col1, col2, col3, col4, col5, col6)
SELECT @Param1, col2, col3, col4, col5, col6
FROM #myTemp
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.