Getting Unknown characters while Fetching from SQL SERVER

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
Rakesh311
Participant
Posts: 36
Joined: Wed Aug 04, 2010 10:53 pm
Location: Banglore
Contact:

Getting Unknown characters while Fetching from SQL SERVER

Post by Rakesh311 »

Hi

I am fetching data from an CHAR(5) COLUMN of an SQL SERVER 2005 database.If the count of number of characters in that column is less than 5,then am getting some unknown characters for the rest...
Example
Column1
AA^@^@^@
aaaaa
b^@^@^@^@

This Unknown character(^@) is not visible from datastage(while viewing the data)

But when i checked the file at the server i found this...this make the string comparison and all fail...


can u guys please help me in resolving this

Thanks
Rakesh
rAKESH
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

First step is always to move it from "unknown character" to known by determining the decimal or hex value of the character. A hex editor would make that simple or you can check your man page for "od" to see what your switches are to output the character in something besides octal.

Or you could change your value of $APT_STRING_PADCHAR (that should be pretty close to the actual name) from 0x0 to 0x20 so they are padded with spaces. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

ps. Just post your questions, please don't send it out via private messaging as well. There's no need and it just upsets the natives.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

pps. The second person personal pronoun in English is spelled "you". Spelling it "u" upsets at least some of the natives.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

LOL... that too.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Rakesh311
Participant
Posts: 36
Joined: Wed Aug 04, 2010 10:53 pm
Location: Banglore
Contact:

Post by Rakesh311 »

Mistakes :oops: Mistakes :oops:

Sorry guys...


Craig thanks for your reply....

I had tried by finding the Ascii value of those Character..but its not working as expected...

And when I set the $APT_STRING_PADCHAR to 0x20 the columns with at-least one character's value is coming perfectly.
But if there is no Character then its not happening.

Example
Column1
A
^@^@^@^@^@

Thanks
Rakesh
rAKESH
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Ctrl-@ is the ASCII NUL character, which is used to pad fixed length strings by default. Setting APT_STRING_PADCHAR to a different character uses that character instead. For the case where SQL Server returns five NUL characters I'd be interested to know what's really stored in SQL Server. You can certainly convert Char(0) to " " in a Transformer stage, but how did the NUL characters get into SQL Server in the first place?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply