Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

non-printing character question 1

Status
Not open for further replies.

wbodger

Programmer
Apr 23, 2007
769
US
Is there a problem with chr(13) getting placed into a field in SQL Server?

wb
 
No. There is no problem with it.

There is a slight bit of weirdness when you are looking at the data in SQL Server Management Studio. The default "output" is to grid, and the grid output does not show chr(13) or tab, or linefeed.

To see what I mean....

Open SQL Server Management Studio.
Open a new query window.

Copy/paste this:

Code:
Declare @Temp Table(Data VarChar(1000))

Insert Into @Temp Values('Line 1' + Char(13) + 'Line 2')

Select * From @Temp

When in "Grid" mode, you will see:

[tt]Line 1 Line 2[/tt]

Now, right click in the query window, click 'Results To' -> Results to text.

Run the code again, and you will see:

[tt]
Data
--------------
Line 1
Line 2
[/tt]

Please note that you need to use Char(13), not Chr(13).

-George
Microsoft SQL Server MVP
My Blogs
SQLCop
twitter
"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Could mess you up later if you try to concatinate something to it, if you didn't remember it was there. Might mess you up on a report or something.

Simi

 
Yes, that is part of my dilemma. It is legacy code that I have inherited, not used often and trying to determine what is truly still an issue.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top