Page 1 of 1

Not able to trim spaces during insert for CHAR data type

Posted: Mon Mar 08, 2010 9:02 am
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

Posted: Mon Mar 08, 2010 9:34 am
by chulett
Of course not, that's how a CHAR works after all, being a fixed-width field.

Posted: Mon Mar 08, 2010 9:42 am
by nagarjuna
It will work with varchar fields only

Posted: Mon Mar 08, 2010 10:00 am
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.

Posted: Mon Mar 08, 2010 10:03 am
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.

Posted: Mon Mar 08, 2010 10:12 am
by kaushal.kumar@igate.com
:P thanku