Need to concatenate two varchar(2000) columns

  • 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.

  • 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

  • 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.

    If everything seems to be going well, you have obviously overlooked something.

    Ron

    Please help us, help you -before posting a question please read[/url]
    Before posting a performance problem please read[/url]

  • "as Combined_Notes" to be removed

    _____________
    Code for TallyGenerator

  • 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