If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back  dBforums > Database Server Software > Microsoft SQL Server > Updating SQL table using an excel file

LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Registered User
Join Date: Nov 2012
Posts: 3
Updating SQL table using an excel file

New to SQL.
I am trying to update a SQL table using an excel file which has 2 columns FMStyle and FMHSNum.
FMStyle is my link to the SQL table.
Here is what I have for code....
Update DataTEST.dbo.zzxstylr
SET hs_num = (select FMHSNum FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0', 'Excel 12.0;Database=c:\temp\StyleHSCodesLoad.xls;HDR=YES ', [Sheet1$]))
Where FMStyle = zzxstylr.style
Everything seems to be ok except for the "Where FMStyle" is giving me a message Invalid Column name on FMStyle.
Do I need to qualify FMStyle and if so how.

Reply With Quote
  #2 (permalink)  
Registered User
Join Date: Jan 2013
Location: Woodland Hills, CA
Posts: 18
MichaelL, try this:

Update zz
zz.hs_num = ex.FMHSNum
from DataTEST.dbo.zzxstylr zz
join OPENROWSET('Microsoft.ACE.OLEDB.12.0', 'Excel 12.0;Database=c:\temp\StyleHSCodesLoad.xls;HDR=YES ', [Sheet1$]) ex
on ex.FMStyle = zz.style

Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On