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
 TRIM for multiple columns

Author  Topic 

Jason2112
Starting Member

17 Posts

Posted - 2009-08-03 : 17:42:13
I have a view that I'm exporting to flat file via SSIS and I get a lot of blank spaces (i.e. if the field is set for 10 characters, and I have 4 characters of data, I get 6 blank characters). I see that I can use the TRIM function, but I need to do this for 25 columns. Is there a quick way to do all columns? Thanks.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-08-03 : 17:44:43
No. Are you using char data type or varchar? What column delimiter are you using?

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

Jason2112
Starting Member

17 Posts

Posted - 2009-08-03 : 17:59:23
quote:
Originally posted by tkizer

No. Are you using char data type or varchar? What column delimiter are you using?



Some are nvarchar, some are nchar (sourced from multiple tables). It's comma delimited in the Data Flow flat file destination.

One thing I should mention is that this also affects fields with no data. So I have a bunch of fields that will always be blank, so I just created them as nvarchar(1) so they would flow through my views. These fields show up with a single blank space in the CSV file ( as , , , rather than ,,,).
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-08-04 : 13:43:14
Do you require unicode data types?

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
   

- Advertisement -