user2869402
user2869402

Reputation: 27

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:-

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?

Upvotes: 0

Views: 52

Answers (1)

ASh
ASh

Reputation: 35646

INSERT INTO table1 (col1,col2) 
SELECT @constant, col2 
FROM table2

Upvotes: 3

Related Questions