Solved

SQL Server Select LEN on XML

Posted on 2013-07-01
4
707 Views
Last Modified: 2013-07-01
What is the best way for me to get a true "Length" on an XML field that was inserted using a HttpWebResponse chunked response and a read buffer like this in VB
streamRead.Read(readBuff, 0, 5120)


This is my select
SELECT LEN(CAST(XmlDoc AS VARCHAR(MAX))) xmlDoc FROM      [dbo].[VOIPXMLTransactionLog]

But it seems to be ignoring spaces?
0
Comment
Question by:lrbrister
[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
  • 2
4 Comments
 
LVL 13

Expert Comment

by:jonnidip
ID: 39291097
Are you sure that spaces are in the variable?
Where are you openinig your file? Maybe in a "visual" editor (just like Internet Explorer)? If so, you may see spaces where there are only tabs, or maybe nothing...
Some viewers/editors apply formatting to XML files.
Please ensure you are not in this case...


Regards.
0
 

Author Comment

by:lrbrister
ID: 39291104
I'm not looking at it in a viewer.

I'm getting a response stream and sending it straight to SQL Server.
0
 
LVL 11

Accepted Solution

by:
lenordiste earned 500 total points
ID: 39291106
that SQL statement looks fine. LEN does take into account spaces so this should give you the result you are looking for. Why do you think it is not working as intended? The only thing I can think of is that LEN does not count trailing spaces!

as a side note, you can also use the function datalength which returns the size in bytes, including trailing blanks:
http://msdn.microsoft.com/en-us/library/ms173486(SQL.90).aspx
0
 

Author Closing Comment

by:lrbrister
ID: 39291173
That was it...the DataLength
0

Featured Post

Independent Software Vendors: 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

Suggested Solutions

The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

752 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