January 27, 2009 at 3:35 pm
I have two columns (notes and resolution), both are varchar(2000); I need to concatenate them and set the results equal to another varchar(2000) column called NoteRes.
I know that I can do so in a select statement like this:
select id, notes + char(13) + char(10) + resolution as Combined_Notes
from tickets where id = 2
But, when I try this error: Incorrect syntax near the keyword 'select'.
declare @cn as varchar(2000)
set @cn = select id, notes + char(13) + char(10) + resolution as Combined_Notes
from tickets where id = 2
print @cn
By the way, the separate notes and resolution columns have no where near 2000 characters in them. Only about 200 per column.
Any help is greatly appreciated.
January 27, 2009 at 5:32 pm
declare @cn as varchar(2000)
select @cn = notes + char(13) + char(10) + resolution as Combined_Notes
from tickets where id = 2
print @cn
_____________
Code for TallyGenerator
January 27, 2009 at 6:21 pm
Sergiy when I run your T-SQL
declare @cn as varchar(2000)
select @cn = notes + char(13) + char(10) + resolution as Combined_Notes
from tickets where id = 2
I get this error message:
Msg 156, Level 15, State 1, Line 2
Incorrect syntax near the keyword 'as'.
Pat_B If my assumption is incorrect disregard the following. If the column noteres in the same table i.e., Tickets then you could update that column using the following:
UPDATE Tickets SET noteres = notes + char(13) + char(10) + resolution
or if noteres is in another table. If not in the same table post the table structures to receive further help.
January 27, 2009 at 11:46 pm
"as Combined_Notes" to be removed
_____________
Code for TallyGenerator
January 28, 2009 at 10:11 am
Thanks for your help. I got this working after removing the AS "Combined_Notes".
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply