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 8910303
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T03:39:23+00:00 2026-06-15T03:39:23+00:00

I have to use a column with a datatype of TEXT in SQL Server

  • 0

I have to use a column with a datatype of TEXT in SQL Server 2005 to store a string that I need formatted with newlines and tab character for example.

prior to calling the stored proc, I added a breakpoint to view the text I’m sending in the text visualizer in VS2010, and all formatting is exactly how I want it to be, but when I go the the cell in the database, and copy out the data, the formatting is lost. From what I can see, every time it a newline character or tab character is present in the string, the text datatype just replaces it with a space. For newlines I’m using vbNewline and for tabs I’m using vbTab or Xml.Formatting.Indented

It’s worth note that I can NOT change the data type of the column, because it’s simply a table i have to use for a specific purpose.

Any suggestions on getting this to format correctly in the database with at datatype of text?

EXAMPLE:

SQL Table Script Representing the table:

CREATE TABLE [dbo].[FooLog](
    [FooID] [int] IDENTITY(1,1) NOT NULL,
    [FooInfo] [text] NULL )

Stringbuilder code:

Dim sb As New StringBuilder()

sb.AppendFormat("{0}{1}", "Some text", vbNewLine)
sb.AppendLine("Some foo bar data")
sb.AppendLine(String.Format("{0}data{1}{0}some more data", vbTab, vbNewLine))

Dim stringToStoreInFooInfo As String = sb.ToString()

Store in db:

db.AddInParameter(cmd, "FooInfo", SqlDbType.Text, stringToStoreInFooInfo)

I’m not reading it back with code at the moment… I’m copying it out of the cell with Ctrl-C or right-click “copy”

  • 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-06-15T03:39:24+00:00Added an answer on June 15, 2026 at 3:39 am

    It does preserve the formatting fine, you’re losing the format by copying out of the SSMS cell.

    Once you’ve got code pulling the text back out you should still have the formatting in place.

    For example if you run the following in SSMS, you’ll lose the newlines. It switches in spaces for other whitespace chars I think.

    Select
    '
    This
        is
    some fomatted
    text
    '
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How to use conditional select query in SQL Server ? I have a column
I have 2 tables that I am working with that use the same column;
I have many tables that use Lookup/Enum references for most of their column values.
I have the following problem: I need to use XSLFO to generate a 2-column
I use SQL Server 2008 and have a table with 5 char typed columns.
I have a table in my SQL Server 2005 database, which has a field
In a table, I have a column called MEMO_TEXT that is a text data
So I got a varbinary(max) column in SQL Server 2005 and it's full of
I have the text <column caption='TZ_Shift' datatype='real' name='[total_millis Parameter]' param-domain-type='any' role='measure' type='quantitative' value='-0.16666666699999999'> which
I am using sql and sql-server I have created a new column in a

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.