line breaks lost in sql server

后端 未结 7 1501
心在旅途
心在旅途 2020-12-18 18:02

I am entering error information into an ErrorLog table in my database. I have a utility class to do this:

ErrorHandler.Error(\"Something has broken!!\\n\\nDe         


        
相关标签:
7条回答
  • 2020-12-18 18:40

    For SQL Server 2008, there is no provision to set "Retain CR\LF on copy or save" to true.

    For this issue, what I did is that, replace char(13) with "\r" and replace char(10) with "\n" like below.

    REPLACE(REPlACE([COLUMN_NAME],char(13), '\r'),CHAR(10),'\n')
    

    And in the code-behind again I've replaced "\r\n" with a break tag.

    I worked out in this way as there was no option provided in SQL 2008 as mentioned above. This answer might be an alternative though.

    Thanks

    0 讨论(0)
提交回复
热议问题