Solved

How to store carriage return in SQL

Posted on 2008-10-15
7
2,143 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
ID: 22725359
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
ID: 22725409
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
ID: 22725412
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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 39

Expert Comment

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

Author Comment

by:MushroomStamp
ID: 22726078
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
ID: 22726560
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
ID: 22732825
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

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Question has a verified solution.

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

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

896 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

11 Experts available now in Live!

Get 1:1 Help Now