[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

How to store carriage return in SQL

Posted on 2008-10-15
7
Medium Priority
?
2,179 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
Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

 
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 Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

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

How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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 demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.

650 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