Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Insert carriage return into sql server table

Posted on 2007-07-31
5
Medium Priority
?
773 Views
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

Thanks
RK
0
Comment
Question by:rk75
  • 3
4 Comments
 
LVL 31

Accepted Solution

by:
Frosty555 earned 1000 total points
ID: 19603497
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'
0
 
LVL 31

Expert Comment

by:Frosty555
ID: 19603524
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.
       char(13)+char(10)

In unix/linux/freebsd, a line break is ONLY a line feed.
      char(10)

On Macs, a line break is ONLY a carriage return
      char(13)
0
 
LVL 31

Expert Comment

by:Frosty555
ID: 19603555
Oh Mac OS X actually uses a linefeed only, just like unix/linux.
Apple and Mac up to OS 9 uses carriage return.

http://en.wikipedia.org/wiki/Newline#Representations
0
 
LVL 1

Expert Comment

by:Vee_Mod
ID: 20658483
Force accepted.
Vee_Mod
Community Support Moderator
0

Featured Post

Restore individual SQL databases with ease

Veeam Explorer for Microsoft SQL Server delivers an easy-to-use, wizard-driven interface for restoring your databases from a backup. No expert SQL background required. Web interface provides a complete view of all available SQL databases to simplify the recovery of lost database

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
MSSQL DB-maintenance also needs implementation of multiple activities. However, unprecedented errors can hamper the database management. In that case, deploying Stellar SQL Database Toolkit ensures fast and accurate database and backup repair as wel…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Viewers will learn how the fundamental information of how to create a table.
Suggested Courses

810 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