[英]How to insert values from a table in another along with other values in sql server?
I'm working on a project in which i need to insert data from one table to another along with another value, lets say I have table1(col1,col2,col3) and i have table2(col2) so i wrote the following:- 我正在一个项目中,我需要将一个表中的数据与另一个值一起插入到另一个表中,可以说我有table1(col1,col2,col3)和table2(col2),所以我写了以下内容:
INSERT INTO table1 (col1,col2) VALUES ((@constant),(SELECT col2 FROM table2))
How to do that knowing that @Constant
is a parameter that has a value used inside a stored procedure? 知道
@Constant
是一个具有在存储过程中使用的值的参数时,该怎么做?
INSERT INTO table1 (col1,col2)
SELECT @constant, col2
FROM table2
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.