Insert carriage return into sql server table

Posted on 2007-07-31
Last Modified: 2010-08-05
I need to insert text value into sql server table which contains line feed (carriage return)
What data type is used for this?
And what character is used for line feed?

Experts Please help

Question by:rk75
    LVL 31

    Accepted Solution

    VARCHAR and TEXT both support carriage return/line feeds.

    A carriage return is CHAR(13)
    A linefeed is CHAR(10)

    So in SQL you can specify a crlf in your stored proc or query like this:

    print 'abc' + char(13)+char(10) + 'def'
    LVL 31

    Expert Comment

    It is noteworthy to mention that line breaks are different in different operating systems.

    In windows and dos, a line break is a CRLF, e.g. a carriage return followed by a linefeed.

    In unix/linux/freebsd, a line break is ONLY a line feed.

    On Macs, a line break is ONLY a carriage return
    LVL 31

    Expert Comment

    Oh Mac OS X actually uses a linefeed only, just like unix/linux.
    Apple and Mac up to OS 9 uses carriage return.
    LVL 1

    Expert Comment

    Force accepted.
    Community Support Moderator

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
    JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
    Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
    Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    9 Experts available now in Live!

    Get 1:1 Help Now