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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Subquery cannot appear in an Insert Values statemement

Status
Not open for further replies.

jez

Programmer
Apr 24, 2001
370
VN
Hi.

The title of this thread is the error i get from the following sql statement.

Code:
INSERT INTO Media_Cart_Items
(cart_id, cart_item_filename, cart_item_filesize, cart_item_full_path)
VALUES     ('286', '***.WMV',
                          (SELECT     Filesize
                            FROM          Media_Delivery
                            WHERE      Filename = '***.WMV'), '**.WMV');

Can anyone tell me how you would acheive this with MS SQL, as this statement would work in other DBs like Oracle etc, so i thought there must be something like it in MS SQL.

Suggestions welcome.
 
Code:
INSERT 
  INTO Media_Cart_Items
     ( cart_id
     , cart_item_filename
     , cart_item_filesize
     , cart_item_full_path )
SELECT '286'
     , '***.WMV'
     , Filesize
     , '**.WMV' )
  FROM Media_Delivery
 WHERE Filename = '***.WMV'
:)

r937.com | rudy.ca
Buy my new book Simply SQL from Amazon
 
Thanks !! That works just fine.

 
Yes, i saw that and removed it for my first test and it worked so....

Thanks,

Jez
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top