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
 importing fixed-width w/o leading spaces

Author  Topic 

albertkohl
Aged Yak Warrior

740 Posts

Posted - 2009-12-03 : 16:12:07
okay, so here's the stroy, i have a data set, it's all in a fixed-width format, and lets say there are only 3 columns

field width
fname 30
mi 1
lname 30

data looks like:
albert
w
kohl

(but there are leading spaces)
when i import the data into sql, (say columns are all varchar)
it comes out like:

|albert________________________|

is there a setting i can adjust so that when SSIS imports the data, it doesnt import the leading spaces? on a table 200 Million rows plus, all these blank values will total up to be a HUGE waste of disk space.


tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-12-03 : 17:20:01
Leading or trailing spaces? In either case, trim it during the import by applying a function to the column.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

albertkohl
Aged Yak Warrior

740 Posts

Posted - 2009-12-03 : 17:54:44
trailing, sorry...

so i'd have to have an SSIS package w/ a tranformation then hu?
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-12-03 : 18:00:05
Yes you need to transform the data.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

albertkohl
Aged Yak Warrior

740 Posts

Posted - 2009-12-03 : 23:25:27
any way to do that using the BCP import tool w/ a format file?
Go to Top of Page
   

- Advertisement -