Solved

How to store carriage return in SQL

Posted on 2008-10-15
7
2,155 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
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

730 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