How to Add Line feed in query result

  • Hello

    I have a query where I have to append line feed in one column result among 8 columns like below

    Month Name Amount PaymentMode

    January - 10 10000 Credit Card [here line feed]xxxx-xxxx-xxxx-9897 [here line feed]Tran Detail-123456

    January - 10 70000 Credit Card [here line feed]xxxx-xxxx-xxxx-9897 [here line feed]Tran Detail-908765

    January - 10 30000 Credit Card [here line feed]xxxx-xxxx-xxxx-9897 [here line feed]Tran Detail-123432

    How can I achieve this, any idea would be appreciated..

    Regards,

  • either: CHAR(10)

    or: CHAR(13) + CHAR(10)

    Wayne
    Microsoft Certified Master: SQL Server 2008
    Author - SQL Server T-SQL Recipes


    If you can't explain to another person how the code that you're copying from the internet works, then DON'T USE IT on a production system! After all, you will be the one supporting it!
    Links:
    For better assistance in answering your questions
    Performance Problems
    Common date/time routines
    Understanding and Using APPLY Part 1 & Part 2

  • Its not working, I have checked it already.

    Any other approach..?

  • please post the code of what you've tried.

    You would also need to send the results to text (not grid)

    Wayne
    Microsoft Certified Master: SQL Server 2008
    Author - SQL Server T-SQL Recipes


    If you can't explain to another person how the code that you're copying from the internet works, then DON'T USE IT on a production system! After all, you will be the one supporting it!
    Links:
    For better assistance in answering your questions
    Performance Problems
    Common date/time routines
    Understanding and Using APPLY Part 1 & Part 2

  • xyzxyzxyzxyz123 (10/26/2010)


    Its not working, I have checked it already.

    Any other approach..?

    adding the line feed as Wayne described will work...but the results will not be visible in SSMS in gridmode.

    because SSMS does not do "multiline" cells, CrLf/CHAR(13) + CHAR(10) characters are replaced with spaces for display purposes.

    change to text mode (control + T) , rerun your query, and confirm the new lines are really in the data.

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • xyzxyzxyzxyz123 (10/26/2010)


    Hello

    I have a query where I have to append line feed in one column result among 8 columns like below

    Month Name Amount PaymentMode

    January - 10 10000 Credit Card [here line feed]xxxx-xxxx-xxxx-9897 [here line feed]Tran Detail-123456

    January - 10 70000 Credit Card [here line feed]xxxx-xxxx-xxxx-9897 [here line feed]Tran Detail-908765

    January - 10 30000 Credit Card [here line feed]xxxx-xxxx-xxxx-9897 [here line feed]Tran Detail-123432

    How can I achieve this, any idea would be appreciated..

    Regards

    Hi Wane and lowell are correct u need to use ctrl+T to view

    Select Char(13)+'Test123465789'

    or if u need space then you can use this it will be showen in grid and in text etc

    Select SPACE(10)+'Test123465789'

    Thanks

    Parthi

    Thanks
    Parthi

  • parthi-1705 (10/26/2010)



    Hello

    I have a query where I have to append line feed in one column result among 8 columns like below

    Month Name Amount PaymentMode

    January - 10 10000 Credit Card [here line feed]xxxx-xxxx-xxxx-9897 [here line feed]Tran Detail-123456

    January - 10 70000 Credit Card [here line feed]xxxx-xxxx-xxxx-9897 [here line feed]Tran Detail-908765

    January - 10 30000 Credit Card [here line feed]xxxx-xxxx-xxxx-9897 [here line feed]Tran Detail-123432

    How can I achieve this, any idea would be appreciated..

    Regards,

    Hi Wane and lowell are correct u need to use ctrl+T to view

    Select Char(13)+'Test123465789'

    or if u need space then you can use this it will be showen in grid and in text etc

    Select SPACE(10)+'Test123465789'

    Thanks

    Parthi

  • parthi-1705 (10/26/2010)



    Hello

    I have a query where I have to append line feed in one column result among 8 columns like below

    Month Name Amount PaymentMode

    January - 10 10000 Credit Card [here line feed]xxxx-xxxx-xxxx-9897 [here line feed]Tran Detail-123456

    January - 10 70000 Credit Card [here line feed]xxxx-xxxx-xxxx-9897 [here line feed]Tran Detail-908765

    January - 10 30000 Credit Card [here line feed]xxxx-xxxx-xxxx-9897 [here line feed]Tran Detail-123432

    How can I achieve this, any idea would be appreciated..

    Regards,

    Hi Wane and lowell are correct u need to use ctrl+T to view

    Select Char(13)+'Test123465789'

    or if u need space then you can use this it will be showen in grid and in text etc

    Select SPACE(10)+'Test123465789'

    Thanks

    Parthi

Viewing 8 posts - 1 through 7 (of 7 total)

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