Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6664079
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:34:13+00:00 2026-05-26T02:34:13+00:00

I am working on some code that dumps data into a table. Some of

  • 0

I am working on some code that dumps data into a table.

Some of the data includes carriage returns.

Eventually, the data will be exported as an HTML-formatted email or in a text file (CSV), or both. I don’t know in advance which export method will be used on this data.

If I write my carriage returns to the database like this:

UPDATE SOME_TABLE
SET TEXT_VALUE = @LineOne + CHAR(13) + CHAR(10) + @LineTwo
WHERE ID = @IDValue

Then it works in the CSV file just fine, but the HTML email gets totally screwed up – it confuses the encoding and displays the email with header and mime information and is totally useless except for debugging.

On the other hand, if I write my carriage returns to the database like this:

UPDATE SOME_TABLE
SET TEXT_VALUE = @LineOne + '<br>' + @LineTwo
WHERE ID = @IDValue

Then it’s the other way around – it works in email but the text file outputs with the actual “br” embedded in the text, as in “LineOne< br>LineTwo”.

Is there a way to represent a carriage return in a way that will produce the same result in both plain text and in HTML?

All of this is running on SQL Server 2008 from inside a T-SQL stored procedure.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T02:34:14+00:00Added an answer on May 26, 2026 at 2:34 am

    I think the most appropriate way is to store all text “as-is” with CR LF and then make the proper manipulations when you fetch the data from the table, ie. convert newlines to
    if you are rendering html, etc.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working with a bar code reader that dumps in data in keyboard mode
I'm working on some code that will DD a block device over SSH, and
I'm working on some code that uses the System.Diagnostics.Trace class and I'm wondering how
I'm working with some code that is confusing me and I'm wondering if I'm
I'm working with some code that widely uses the idiom of returning a pointer
We are working with some legacy code that accesses a shared drive by the
Ok, this is a curly one. I'm working on some Delphi code that I
I have been working on some legacy C++ code that uses variable length structures
I'm trying to get some code working that a previous developer has written. Yep,
I'm working with some number crunching code that, by its nature, is floating-point intensive

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.