Reputation: 44312
I have a select that returns employee IDs of type int. I'd like to use these empId values as part of an insert. Basically, I need to loop through all IDs, inserting them. But how is that does done?
I know a cursor can be used for this scenario but isn't there a way to do it without the cursor?
Upvotes: 0
Views: 181
Reputation: 5291
You can do:
INSERT INTO SomeTable
(Column1, Column2, Column3)
SELECT ColumnA, ColumnB, ColumnC
FROM OtherTable
WHERE ...
Upvotes: 0
Reputation: 16955
INSERT INTO
table2
(
employeeID
)
SELECT
employeeID
FROM
table1
Upvotes: 3