?
Solved

How to store carriage return in SQL

Posted on 2008-10-15
7
Medium Priority
?
2,170 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Technology Partners: 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!

 
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 93

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 1500 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
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…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

770 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