Update table with multiline comments

  • Hi All,

    How to update column with multiline coments.

    eg. I need to update Notification column in my table as below.

    Exit Formalities Notification sent to:

    Employee: LastName, FirstName

    EmployeeEmail: EmployeeEmailAddress

    Is it possibe?

    Please give an ideas.

    Thanks

    Abhas.

  • abhas (4/14/2014)


    Hi All,

    How to update column with multiline coments.

    Add "carriage return" and "line feed" characters, see the example

    😎

    SELECT 'THIS IS A COMMENT LINE 1' + CHAR(13) + CHAR(10) + 'THIS IS LINE 2'

    Output

    ----------------------------------------

    THIS IS A COMMENT LINE 1

    THIS IS LINE 2

  • It can be done but I'm not entirely sure what you want. Are the LastName, FirstName and EmployeeEmailAddress' coming from a query? Can you give us a bit more information about what you want please? For example do you want to do this in SSRS or as part of a query?


    On two occasions I have been asked, "Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?" ... I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question.
    —Charles Babbage, Passages from the Life of a Philosopher

    How to post a question to get the most help http://www.sqlservercentral.com/articles/Best+Practices/61537

  • While executing following script please see results to text...And I used '*' considering you don't have one in the field where you want to do it ... But I believe there has to be a easy way out too

    DECLARE @tab TABLE

    (

    COMMENT VARCHAR(100)

    )

    INSERT INTO @tab(COMMENT)

    SELECT 'Exit Formalities Notification sent to:' UNION ALL

    SELECT 'Employee: LastName, FirstName' UNION ALL

    SELECT 'EmployeeEmail: EmployeeEmailAddress'

    DECLARE @COMM VARCHAR(1000)

    SELECT @COMM = REPLACE(STUFF((SELECT '*' + COMMENT FROM @tab

    FOR XML PATH ('')),1,1,''),'*',CHAR(13))

    SELECT @COMM

  • Thanks friends,

    Employee: @LastName, @FirstName

    EmpEmail: @StudentEmailAddress

    The above values are coming from query.

    Thanks

    Abhas.

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply