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
 General SQL Server Forums
 New to SQL Server Programming
 csv data dropping leading 000 on import

Author  Topic 

smorty44
Yak Posting Veteran

93 Posts

Posted - 2008-03-28 : 09:26:30
I am importing csv files using dts with a filedsn pointed to the folder that contains the csv files. Some of these csv's are too big to open in notepad for me to be able to set the datatypes as I see them so I'm letting sql create the tables on import and hope the datatypes get set correctly. I have found some data that is being changed on the import like "0001" has come in as "1". What datatype should I set so the leading zeros are not dropped? Also, what other conversions should I look out for that might get changed inappropriately? Thx

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-03-28 : 09:29:01
VARCHAR keeps leading zeros. INT's don't.



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

pravin14u
Posting Yak Master

246 Posts

Posted - 2008-03-28 : 09:35:47
While importing, just change the datatype of the INT's(Which are by default given by DTS) to VARCHAR


Prakash.P
The secret to creativity is knowing how to hide your sources!
Go to Top of Page

smorty44
Yak Posting Veteran

93 Posts

Posted - 2008-03-28 : 09:37:26
I must be doing something wrong. Even when setting the table to varchar it drops the leading zeros and also changes this "WKCP" to null.
Go to Top of Page

smorty44
Yak Posting Veteran

93 Posts

Posted - 2008-03-28 : 09:43:33
i notice when I look at column mappings and transformations and change the int to varchar it reads that the source column is integer null. Would that affect my results?
Go to Top of Page

pravin14u
Posting Yak Master

246 Posts

Posted - 2008-03-28 : 09:56:37
Sorry, Can you explain clearly? I dont think there is an option to see/change the data type of the "columns" of the file that you are trying to import?




Prakash.P
The secret to creativity is knowing how to hide your sources!
Go to Top of Page

smorty44
Yak Posting Veteran

93 Posts

Posted - 2008-03-28 : 10:11:33
I'm not sure how to explain it yet, I'm going to try some different options and see what happens. Thank you for trying to help. I'll post a better explaination after I investigate furtherk, I don't want to waste your time.
Go to Top of Page
   

- Advertisement -