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 2000 Forums
 Import/Export (DTS) and Replication (2000)
 Import Excel data to SQL

Author  Topic 

TVMom
Starting Member

4 Posts

Posted - 2009-01-27 : 14:07:40
I have an Excel spreadsheet that contains data I want to import into existing SQL tables and have written a script to do so. For the most part, I've been successful but I cannot seem to overcome the issue of leading zeros in text field and text fields that contain a value of zero. The import drops leading zeros and converts fields containing only zeros to null. I've checked the formatting on my Excel fields and SQL fields and both are set to text. Anyone have a way of overriding this conversion?

TVMom
Starting Member

4 Posts

Posted - 2009-01-28 : 10:47:25
Hurray! I've found something that works. I've set IMEX=1 in my query which handles the dropping leading zeros problem. This, however, did NOT solve my bringing in 0 as null issue. To resolve this, in my spreadsheet, I've set my field value as =Text(0,"@"). Excel evaluates this as 0 in a text format. The problem I was having had nothing to do with SQL and everything to do with how Excel evaluates 0 when formatted as text. As long as I've been struggling with this problem, I can't imagine I'm the only one. I hope this is helpful to someone else as well.
Go to Top of Page
   

- Advertisement -