Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

SQL Server Select LEN on XML

Posted on 2013-07-01
4
Medium Priority
?
737 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
  • 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 2000 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

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!

Question has a verified solution.

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

This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

772 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