Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

INSERT Query with Sub-Query?

Status
Not open for further replies.

jchastai

Programmer
Oct 11, 2001
31
US
Is it possible to have a SELECT query insided of an INSERT Query?

i.e. -
INSERT INTO Table1 (ID, Type, etc ...)
VALUES (1, SELECT Type FROM Table2 WHERE ...., etc ...)

I thought it sounded reasonable enough, but I am getting errors. Just an attempt to lighten the number of hits on the database.

Thanks for your help.
 
Here is the syntax from Sql server help.

Use a SELECT subquery to specify the data values for one or more rows.

INSERT INTO MyTable (PriKey, Description)
SELECT ForeignKey, Description
FROM SomeView

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top