Solved

SQL Server Select LEN on XML

Posted on 2013-07-01
4
714 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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
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…
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
Via a live example, show how to shrink a transaction log file down to a reasonable size.

635 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