Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Missing Newline when importing Excel data

Posted on 2011-02-16
7
Medium Priority
?
1,764 Views
Last Modified: 2012-05-11
I have an excel file that has been created from a Sharepoint data source..

That excel file has a cell that includes a new line in the middle of the data.

When I import that data using the Import wizard in SQL 2008, that new line character is dropped.

Any ideas how I can prevent that from happening?
0
Comment
Question by:MWilliamsBolton
[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
  • 4
  • 3
7 Comments
 
LVL 40

Expert Comment

by:lcohan
ID: 34907598
It may not be "dropped" but not translated correctly. I believe in SQL a "new line" as you describe it you should have a ENTER = CRLF (0D0A in hex) and not just a LF(0A in hex) as new line indicator. MAke sure you have the appropriate data in excel or chose the right import format for line terminator in sql then it should work fine.
0
 

Author Comment

by:MWilliamsBolton
ID: 34908913
I tried to make the problem simpler by using Excel and that hasn't helped - just confused things.

I have written something that looks at every character in the SQL field and outputs the ASCII value.. I can now explain the problem a little better..

I have a text entry in Sharepoint that has a new line in the middle of it. When I export that to Excel and then import the Excel file, the new line is represented as LF (ascii 10).

However, when I import the data into SQL from Sharepoint using SSIS, the new line is replaced with a space (character 32). Do you know how I can stop this happening?
0
 

Author Comment

by:MWilliamsBolton
ID: 34909000
THe results from sharepoint will be passed to SSIS using XML. I suspect this will be part of the problem but I have no idea how to address it.. :-((
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 40

Accepted Solution

by:
lcohan earned 2000 total points
ID: 34909620
Do you have the EXCEL document created on a folder accessible to your SQL server? Then you could try import from EXCEL by using SQL commends and OLEDB like in the article below:

http://support.microsoft.com/kb/306397
0
 

Author Comment

by:MWilliamsBolton
ID: 34910189
The problem is I would need to use SSIS services to populate the Excel file. That process uses Sharepoint web services which uses XML. A new line is not recognised as a a new line when it is put in an XML file. It needs encoding which is not possible in Sharepoint without allowing the field to be formatted.. That is my only way forward I think. Thanks for your help..
0
 

Author Closing Comment

by:MWilliamsBolton
ID: 34910191
Thanks for your help..
0
 
LVL 40

Expert Comment

by:lcohan
ID: 34910299
If the input is an XML file and you don't need to mandatory generate your EXCEL file see maybe you could use the SP example below to read in the XML directly into your SQL database:


CREATE PROCEDURE dbo.my_XML_update
      @XMLData NTEXT,
      @myId SMALLINT
AS
SET NOCOUNT ON

-- Retrieve XML data
DECLARE @hocDoc INT

DECLARE @Comments NVARCHAR(2048)

EXEC SP_XML_PREPAREDOCUMENT @hocDoc OUTPUT, @XMLData

-- OPEN XML
-- Param1 is Pointer to DOC
-- Param2 is XML doc hiearchy
-- Param3 is Use Element Structure rather than Attributes


SELECT
      ContactId,
      ContactName
INTO
      #tmpContact
FROM
      OPENXML(@hocDoc, '/root/Contact', 2)
WITH (ContactId  INTEGER, ContactName NVARCHAR(50))

--this is how you populate the contact xml
SELECT Contact.ContactId,
            ISNULL(Contact.ContactName, '') AS ContactName
FROM #tmpContact Contact, Contact C
WHERE      Contact.ContactId = C.Id
ORDER BY      Contact.ContactName
FOR XML AUTO, ELEMENTS

-- Then you can do an INSERT
INSERT INTO Contact (Id, ContactName)
      SELECT ContactId,ContactName
      FROM #tmpContact

--or an UPDATE
UPDATE Contact SET ContactName = t.ContactName
FROM #tmpContact t
                  WHERE      contact.Id = #tmpContact.ContactId
            
-- Drop the temp Table
DROP TABLE #tmpContact

-- and MUST release XML doc to avoid memeory issues
EXEC SP_XML_REMOVEDOCUMENT @hocDoc
GO
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone 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

Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
When trying to connect from SSMS v17.x to a SQL Server Integration Services 2016 instance or previous version, you get the error “Connecting to the Integration Services service on the computer failed with the following error: 'The specified service …
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

610 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