Skip to content
Archive of posts tagged insert

Insert Results of Stored Procedure Into Table

Retrieving the result set from a stored procedure has historically proven to be a difficult task. Fortunately with the advent of OPENROWSET, our life as developers has become much simpler. Using openrowset is very simple when we do not have procedures that take parameters, However when parameters become involved the game changes, however [...]

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 [...]