Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 SSIS and Import/Export (2005)
 Excel to SQL Blank Rows

Author  Topic 

hollyquinn
Starting Member

31 Posts

Posted - 2009-02-02 : 09:32:20
Hi, I'm using the following query to import data from an Excel spreadsheet into an existing SQL table.

Insert into tblRfes Select * FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0',
'Excel 8.0;Database=C:\Documents and Settings\hadams\My Documents\Astar\RFESTEST1.xls;HDR=YES',
'SELECT * FROM [Sheet4$]')

I've had previous problems, but the problem I'm running into now is that when I run the query, it inserts over 1000 rows of blank data. Every column contains a null value. Can anyone give me an idea of why this is happening?? This is my first time importing into SQL Server and i'm really frustrated with it.

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-02-02 : 09:36:37
Insert into tblRfes Select * FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0',
'Excel 8.0;Database=C:\Documents and Settings\hadams\My Documents\Astar\RFESTEST1.xls;HDR=YES',
'SELECT * FROM [Sheet4$]') AS f
where a1 > ''



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

hollyquinn
Starting Member

31 Posts

Posted - 2009-02-02 : 10:39:12
quote:
Originally posted by hollyquinn

Hi, I'm using the following query to import data from an Excel spreadsheet into an existing SQL table.

Insert into tblRfes Select * FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0',
'Excel 8.0;Database=C:\Documents and Settings\hadams\My Documents\Astar\RFESTEST1.xls;HDR=YES',
'SELECT * FROM [Sheet4$]')

I've had previous problems, but the problem I'm running into now is that when I run the query, it inserts over 1000 rows of blank data. Every column contains a null value. Can anyone give me an idea of why this is happening?? This is my first time importing into SQL Server and i'm really frustrated with it.


Peso, thanks so much! it works!
Go to Top of Page
   

- Advertisement -