January 24, 2013 at 12:36 pm
Hello, I am working on a project that requires XML in a format that I have not worked with before. Some of the need to include the tag name with the actual column value inside the tag as well. For example:
This is from a sample output provided from a customer.
<p2:patient-working p1:value="Y"></p2:patient-working>
Any ideas on how to white SQL to accomplish this?
January 24, 2013 at 7:00 pm
Try this:
DECLARE @XML XML = CAST('<p2:patient-working p1:value="Y"></p2:patient-working>' AS XML)
You'll get:
Msg 9459, Level 16, State 1, Line 1
XML parsing: line 1, character 33, undeclared prefix
So I don't think you'll be able to work with it as a SQL XML data type.
My thought question: Have you ever been told that your query runs too fast?
My advice:
INDEXing a poor-performing query is like putting sugar on cat food. Yeah, it probably tastes better but are you sure you want to eat it?
The path of least resistance can be a slippery slope. Take care that fixing your fixes of fixes doesn't snowball and end up costing you more than fixing the root cause would have in the first place.
Need to UNPIVOT? Why not CROSS APPLY VALUES instead?[/url]
Since random numbers are too important to be left to chance, let's generate some![/url]
Learn to understand recursive CTEs by example.[/url]
[url url=http://www.sqlservercentral.com/articles/St
January 24, 2013 at 7:21 pm
The "Y" value is actually queried from the database and could be either "Y" or "N".
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply