Search This Blog

Update a table from an Excel sheet using OpenRowset

Another method without using the dts package


IF OBJECT_ID('tempdb..#temp')is not null
DROP TABLE #temp
create table #TEMP ( PK int, received datetime)
insert into #temp
SELECT * FROM OPENDATASOURCE('Microsoft.Jet.OLEDB.4.0',
'Data Source=c:\UrExcelFile.xls;Extended Properties=Excel 8.0')...Sheet1$ -- put ur excel filename and sheetname

Update urTable
set received =t.received
from aaa
inner join #temp t
ON urTable.PK = t.PK

DROP TABLE #temp

1 comment:

Leslie Lim said...


I have found your blogs to be friendly and welcoming. Thanks for making this one. I really enjoy reading and surfing it. Try to visit my site @ www.imarksweb.org

Liam