April 28, 2007 at 8:47 am
Is there a way to insert a carriage return within a line of tSQL, such as for an address:
a.Address1 + "carriage return"
+ a.Address2
Thanks!
April 28, 2007 at 9:02 am
+ char(13)
April 28, 2007 at 3:36 pm
+ CHAR(13) + CHAR(10) +
If other strings are NVARCHAR and result must be NVARCHAR you need to use
+ NCHAR(13) + NCHAR(10) +
_____________
Code for TallyGenerator
April 28, 2007 at 8:59 pm
this works too, if a bit weird looking:
declare @cr varchar(2)
set @cr = '
'
---------------------------------------
elsasoft.org
April 30, 2007 at 5:16 am
While it's possible, I wouldn't recommend putting in control chars into your data.
Eventually, it's very likely it will give you more troubles than joy.
Should you, by any chance, need to bcp out a column that has a format like
adress <cr> more adress
..it won't work very well, since the <cr> will mess everything up.
Better to format your adresses after you have retrieved it, than to store stuff like <cr> <lf> <tab> and such with the 'real' data.
/Kenneth
April 30, 2007 at 5:50 am
Really appreciate the help. Thanks!
Sam
May 1, 2007 at 9:43 am
I have tried the following but the result ignores the carriage return line feed:
TSQL:
DECLARE @print_line VARCHAR (30)
SET @print_line = 'Line 1'+ CHAR(13) + CHAR(10) + 'Line 2'
SELECT @print_line
Result:
Line 1 Line 2
Any idea as to what I am doing wrong?
Howard
May 1, 2007 at 10:00 am
May 1, 2007 at 10:12 am
That's why in many Address tables, you have columns for AddressLine1, AddressLine2, etc.
You'll be better off in the long run if you follow Kenneth's advice.
---------------------------------------
elsasoft.org
May 1, 2007 at 10:54 am
Thanks to everyone for the answers and advice.
Howard
Viewing 10 posts - 1 through 9 (of 9 total)
You must be logged in to reply to this topic. Login to reply