TSQL insert from select - INSERT INTO SELECT


Please contribute by voting. Thanks!

Do you need to insert data into a table that comes from another table / a select-query? No problem, this is how it's done...

INSERT INTO TableA (columnA, columnB, columnInt, columnVarChar)
SELECT      TableB.columnZ, TableB.columnY, 123, 'foo bar'
FROM        TableB
WHERE       TableB.columnInt2 = 256;

Article created: May 29 '18. Edited May 29 '18.

1 Comment

Robert Bengtsson [1]  •  Mar 24 '19  •   •  Reply

Thanks, this is really useful!

Your comment

You need to sign up / log in to comment this article


Created by Faith Logan [6] May 29 '18

Share article

Do you know about

Domain-driven Design (DDD)?

Write an article