Skip to content
Archive of posts tagged select into

Insert Results of Query Into Table

There are a few ways to insert query results into another table. The most common way is to use the standard insert statement. This would insert query results into a table that already contains data.

INSERT INTO dbo.Users
(
Username
,FirstName
,LastName
,IsSuperUser
,AffiliateId
,Email
,DisplayName
,UpdatePassword
)
SELECT
Username
,FirstName
,LastName
,IsSuperUser
,AffiliateId
,Email
,DisplayName = DisplayName + ‘ SuperUser’
,UpdatePassword
FROM dbo.NewUsers nu
WHERE nu.IsSuperUser = 1

This way is most efficient if you [...]