Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 How do I see char(13) in varchar(max) column

Author  Topic 

groadssql
Starting Member

9 Posts

Posted - 2011-07-22 : 09:27:54
I know my varchar has carriage returns, char(13), in it. Is there a tsql statement or function that lets me see the value of the characters in my data? There may also be some other chars that I need to see as well. So help seeing the chars will be wonderful.

GAR

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2011-07-22 : 09:56:42
There is nothing in SQL Server Management Studio that I know of that is the equivalent of "View -> White Spaces" in Visual Studio.

You may be able to improvise by checking for specific characters, and even make it more sophisticated to pick up all kinds of non-alphanumeric characters - but none of that is out-of-the-box functionality in SSMS.
DECLARE @x VARCHAR(32);
SET @x = 'abc'+CHAR(13)+'abc';

-- Check it has char13
IF @x LIKE '%'+CHAR(13)+'%' PRINT 'Has Char(13)';

-- cast it as varbinary and look through it painfully.
SELECT CAST(@x AS VARBINARY);
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2011-07-22 : 10:00:58
this will return the position of 1st char(13), loop it to find all char(13)

select charindex(char(13), @thestr)



KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -