Am trying to read a fixed width char field from the database.
I can see that the file on the output has trailling 0s so in HEX it would be say
50 2D 00 00 00 00
I want to trim these or atleast replace with spaces.
I have tried convert(char(000)," ", ..)
also have set the APT_PADCHAR to 0x20
This doesn't seem to be working.
Char / varchar reading and trimming trailing Nulls char(0)
Moderators: chulett, rschirm, roy
Hi,
From what I understand you simply need to change the data type to varchar to resolve your issue.
Please reply if this is not the case.
IHTH,
From what I understand you simply need to change the data type to varchar to resolve your issue.
Please reply if this is not the case.
IHTH,
Roy R.
Time is money but when you don't have money time is all you can afford.
Search before posting:)
Join the DataStagers team effort at:
http://www.worldcommunitygrid.org
![Image](http://www.worldcommunitygrid.org/images/logo.gif)
Time is money but when you don't have money time is all you can afford.
Search before posting:)
Join the DataStagers team effort at:
http://www.worldcommunitygrid.org
![Image](http://www.worldcommunitygrid.org/images/logo.gif)
Re: Char / varchar reading and trimming trailing Nulls char
Hi roy.I have tried with datatype varchar with no lenght and also with max length.
Here are the diff examples
ie.e if the input is HEX= "50 2D 00 00 00 00"
Then if I put a varchar(max=2) I will get "50 2D" correctly,
If I put varchar I get "50 2D 00 00 00 00"
If I put varchar(max=4) I will get "50 2D 00 00"
Here are the diff examples
ie.e if the input is HEX= "50 2D 00 00 00 00"
Then if I put a varchar(max=2) I will get "50 2D" correctly,
If I put varchar I get "50 2D 00 00 00 00"
If I put varchar(max=4) I will get "50 2D 00 00"
Reading with varchar won't do, but reading char and type-casting to varchar should do it.
Roy R.
Time is money but when you don't have money time is all you can afford.
Search before posting:)
Join the DataStagers team effort at:
http://www.worldcommunitygrid.org
![Image](http://www.worldcommunitygrid.org/images/logo.gif)
Time is money but when you don't have money time is all you can afford.
Search before posting:)
Join the DataStagers team effort at:
http://www.worldcommunitygrid.org
![Image](http://www.worldcommunitygrid.org/images/logo.gif)
Re: Char / varchar reading and trimming trailing Nulls char
Roy,
I changed the reading column type from varchar to char(8).
In a transformer I mapped it to varchar.
Same issue.
Is there some other way I should be converting
I changed the reading column type from varchar to char(8).
In a transformer I mapped it to varchar.
Same issue.
Is there some other way I should be converting
Re: Char / varchar reading and trimming trailing Nulls char
If I perform a simpel tr on the file the nulls vanish.