all groups > sql server new users > june 2005 >
You're in the

sql server new users

group:

How to identify hidden character in string


How to identify hidden character in string Rod Gilchrist
6/28/2005 9:30:58 AM
sql server new users:
I am trying to do an update where I first cast as string as a INT and get
back the following message:

Server: Msg 245, Level 16, State 1, Line 1
Syntax error converting the nvarchar value '725
' to a column of data type int.

When I past the offending column contents into Word it shows two trailing
spaces. But they must actually be something else because rTrim doesn't
remove them.

I figure they are something else that I will have to use a replace to
replace with but I can't figure out what they are.

Any suggestions people? Anyone have a query that brings back what the
offending characters are?

Rod

Re: How to identify hidden character in string Rod Gilchrist
6/28/2005 10:05:00 AM
Never mind. Turns it there was a Char(10) and a Char(13) in the string. Just
did the ol' trial and error approach.

Still, it would be nice to find a query to tell one what kind of character
is hidden in there, no?

Rod

Re: How to identify hidden character in string Sue Hoegemeier
6/28/2005 11:20:51 PM
Look up the CHAR and ASCII functions in books online. Both
have the same example showing how to use CHAR and ASCII to
return the ascii codes and characters for a string.

-Sue

On Tue, 28 Jun 2005 10:05:00 -0700, "Rod Gilchrist"
[quoted text, click to view]
Re: How to identify hidden character in string Rod Gilchrist
6/29/2005 3:14:57 PM
Thanks for the reply Sue. Actually I did run the code, but in fact it just
brings back the characters as hidden characters (empty spaces).

What I'd like to see for instance is the empty space replaced with the Char
value, such as Char(9) for tab or something.

Rod

[quoted text, click to view]

Re: How to identify hidden character in string Sue Hoegemeier
7/4/2005 8:23:46 PM
ASCII does return the ASCII code. If you need it wrapped in
the Char() you could just adjust the example along the lines
of:
SELECT 'CHAR(' + CAST(ASCII(SUBSTRING(@string, @position,
1)) as varchar(20))+ ')'
But you already have what you need without doing that. If it
returns 9, that's the same as Char(9)

-Sue

On Wed, 29 Jun 2005 15:14:57 -0700, "Rod Gilchrist"
[quoted text, click to view]
AddThis Social Bookmark Button