Solved

How to store carriage return in SQL

Posted on 2008-10-15
7
2,141 Views
Last Modified: 2010-04-12
There is an address list that is kept in Excel 2003 with 3 Columns ( Name, CompName, CompAddress). I am building a web-app that will allow users to edit the maililng list. First step was to bring the data into MSSQL 2008. No biggie. Except, in the CompAddress field, the originator had used carriage returns in order to format so she could do a mail merge in word and the address would be formatted correctly.

On SQL server in the ComAddress field after the import I see a "square" (assuming it always shows the for special characters).  My problem is, how do I store that special character? I was hoping to just have a method that is an insert/update, just don't know how to store that same special character.

In excel she said she uses the Alt-Enter to get carriage return inside a cell.

I am open to Suggestions on solving differently.
0
Comment
Question by:MushroomStamp
7 Comments
 
LVL 39

Expert Comment

by:BrandonGalderisi
Comment Utility
If you insert the following data

'123 Main Street
Anytown, USA 12345'

And then select it you will get back

123 Main Street
Anytown, USA 12345
0
 
LVL 2

Expert Comment

by:EruditeMonkey
Comment Utility
If you need to use CR or new line in a query you can use Char(10) and Char(13) respectively.
0
 

Author Comment

by:MushroomStamp
Comment Utility
Ok. well I assume you mean if a user uses "Shift-Enter" in a Text Box.  Ok I can see that. Only hope MS Word when importing from an ODBC source can interpret that.  Unfortunately though, when I pull the Data and set the value of Text Box with one of the old Excel created special characters, it is not showing a carriage return.
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 39

Expert Comment

by:BrandonGalderisi
Comment Utility
it's not "SHOWING" or selecting with it.  You shouldn't SEE anything different in SQL.
0
 

Author Comment

by:MushroomStamp
Comment Utility
Except as I stated. The data that was imported into SQL from Excel has a "box character" that you can see.
0
 
LVL 92

Expert Comment

by:Patrick Matthews
Comment Utility
Excel uses ANSI character 10 for in-cell line breaks, while usually a line break is ANSI 10 and 13.

Try replacing CHAR(10) with CHAR(10) + CHAR(13).
0
 
LVL 51

Accepted Solution

by:
Mark Wills earned 500 total points
Comment Utility
Needs to be in the correct sequence :

try this as an example :

print 'thequick' + char(13)+char(10)+ 'brown' + char(13)+char(10)+  'furry thingy'

then check out the messages tab.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

SQL Server engine let you use a Windows account or a SQL Server account to connect to a SQL Server instance. This can be configured immediatly during the SQL Server installation or after in the Server Authentication section in the Server properties …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

762 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

12 Experts available now in Live!

Get 1:1 Help Now