Not able to trim spaces during insert for CHAR data type

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
kaushal.kumar@igate.com
Participant
Posts: 77
Joined: Tue Apr 14, 2009 4:03 am

Not able to trim spaces during insert for CHAR data type

Post by kaushal.kumar@igate.com »

Hi,

While inserting data for CHAR data type field ,i am not able to trim the spaces .In Database i could able to see spaces.I tried with both TRIM and TrimLeadingTrailing functions. I am using SQL Server 2005 database as target. Please let me know how to resolve the issue.


Regards
Kaushal
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Of course not, that's how a CHAR works after all, being a fixed-width field.
-craig

"You can never have too many knives" -- Logan Nine Fingers
nagarjuna
Premium Member
Premium Member
Posts: 533
Joined: Fri Jun 27, 2008 9:11 pm
Location: Chicago

Post by nagarjuna »

It will work with varchar fields only
Nag
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Is someone telling you to do this? If so, they are messing with you. And as noted, if you really need to store a variable length string with no padding characters, your target database field will need to be changed to a Varchar.
-craig

"You can never have too many knives" -- Logan Nine Fingers
abhijain
Participant
Posts: 88
Joined: Wed Jun 13, 2007 1:10 pm
Location: India

Post by abhijain »

CHAR is fixed width. You won't be able to do that.

VARCHAR is variable length. Here you can trim the extra spaces.
Rgrds,
Abhi
kaushal.kumar@igate.com
Participant
Posts: 77
Joined: Tue Apr 14, 2009 4:03 am

Post by kaushal.kumar@igate.com »

:P thanku
Post Reply