December 19, 2008 at 12:25 am
I'm trying to add data to the first four columns (of 10) to an excel spreadsheet through the use of OpenRowSet.
Normally, you would do this like:
INSERT INTO OPENROWSET('Microsoft.Jet.OLEDB.4.0','Excel 8.0;Database=C:\Test.XLS', 'select {columnlist} from [Sheet1$]')
However, some of those columns in Excel have spaces in their name.
How do you specify those columns in the {columnlist}?
The only way I've been able to figure out is to use the Hdr=No and to specify the columns as F1,F2, etc.
INSERT INTO OPENROWSET('Microsoft.Jet.OLEDB.4.0','Excel 8.0;Database=C:\Test.XLS;Hdr=No', 'select F1,F2,F3,F4 from [Sheet1$]')
Wayne
Microsoft Certified Master: SQL Server 2008
Author - SQL Server T-SQL Recipes
December 19, 2008 at 1:35 am
put them in brackets []
[column one], [column two]
December 19, 2008 at 7:35 am
Thanks. I had tried this, and it didn't work. But it's working now for me.
Wayne
Microsoft Certified Master: SQL Server 2008
Author - SQL Server T-SQL Recipes
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply