Question : Insert single column into table using select statement

Hello everyone,

I have a table with over 10 columns.  I want to insert data into only one of the column using data from another column.  My SQL looks  like this, but it's not working.

INSERT INTO dbo.dcx_dealer_code (Dealer_Code) Values
(select distinct detail.Dealer_Code from dbo.dcx_warranty_detail_report detail
LEFT OUTER JOIN dbo.dcx_dealer_code dcode ON
dcode.Dealer_Code = detail.Dealer_Code
WHERE dcode.Dealer_Code is null)

I have done this before, but the destination columns always matched the source columns, this time I can't figure this out.  Any prompt help will be much appreciated.

Answer : Insert single column into table using select statement

Try this:

INSERT INTO dbo.dcx_dealer_code (Dealer_Code)
(select distinct detail.Dealer_Code from dbo.dcx_warranty_detail_report detail
LEFT OUTER JOIN dbo.dcx_dealer_code dcode ON
dcode.Dealer_Code = detail.Dealer_Code
WHERE dcode.Dealer_Code is null)
Random Solutions  
 
programming4us programming4us