Yesterday, I was in the situation where I needed to import the
data from an Excel spreadsheet into a table in SQL Server. No problem - use DTS import/export wizard right? Well that is what I did, but after I uploaded it, the user kept coming back and
giving me a new editted version of the spreadsheet to upload. Second time, no problem (should be the last right?). Delete the rows and then the import data wizard again...I think it took at least
4 times before we had the final spreadsheet to upload. I wish I had saved the DTS package the first time, but I didn't (it wouldn't be used again after the final upload anyways)
Next time I will use the OPENROWSET function. This will allow me to edit the SQL as needed
each back and forth. Check it out, the following SQL will take all the records out of my Excel spreadsheet and insert them into the BonusUpload table:
GO
DELETE BonusUpload
GO
SELECT *
INTO BonusUpload
FROM
OPENROWSET('Microsoft.Jet.OLEDB.4.0'
,'Excel 8.0;Database=C:\_projects\CorpAdmin\reports\numbers.xls'
,'SELECT * FROM [Sheet1$]'
)
A great alternative to using the DTS import/export wizard