Viewing 15 posts - 61 through 75 (of 140 total)
Here is a quick example to shred that xml to a flat table:
DECLARE @xml XML
SET @xml = '<employees>
<employee>
<emp_id>1</emp_id>
<emp_name>Bob</emp_name>
<skills>
<skills_id>1</skills_id>
<skills_id>tsql</skills_id>
<skills_id>2</skills_id>
<skills_id>SSRS</skills_id>
<skills_id>3</skills_id>
<skills_id>SSAS</skills_id>
<skills_id>4</skills_id>
<skills_id>SSIS</skills_id>
<skills_id>5</skills_id>
<skills_id>Replication</skills_id>
</skills>
</employee>
<employee>
<emp_id>2</emp_id>
<emp_name>Frank</emp_name>
<skills>
<skills_id>1</skills_id>
<skills_id>tsql</skills_id>
<skills_id>2</skills_id>
<skills_id>SSRS</skills_id>
<skills_id>3</skills_id>
<skills_id>SSAS</skills_id>
</skills>
</employee>
</employees>
'
SELECT e.c.value('(emp_id)[1]', 'int') AS emp_id
, e.c.value('(emp_name/text())[1]', 'varchar(50)') AS emp_name
, s.c.value('(.)[1]', 'varchar(50)') AS skills_id
FROM...
March 1, 2013 at 7:14 am
Hi,
Personally, if I was to approach this from the SQL server side of things, I would do something like the following. It isn't pretty, but it works and I hope...
February 1, 2013 at 6:51 am
Hugo Kornelis (1/24/2013)
If forced to make a choice based on...
January 24, 2013 at 1:36 am
hb21l6 (1/23/2013)
Thank you arthurolcot very very much! That did exactly what I was looking for.Many thanks
David
No problem.. Thanks for the feedback.
January 23, 2013 at 2:41 am
Hi,
I think you are very close, does this updated final query do what you need it to do or get you closer?
select
C.value('(Customers/CustomerID)[1]','INT') as CusID,
C.value('(Customers/ContactName)[1]','varchar(50)')...
January 23, 2013 at 2:09 am
Hi, One way of approaching it could be to use a CTE + sub query similar to this:
;WITH xCTE (CoveredEntity) AS
(
SELECT DISTINCT CoveredEntity
FROM @t
)
SELECT CoveredEntity AS '@Name',
(
SELECT CoverageLoser AS...
December 17, 2012 at 1:40 pm
As Ray mentions, the xml methods are perfect for this.. here is an example based on your xml
DECLARE @xml XML
SET @xml = '<server name="Server1">
<log>
<logItem type="LogDate">
<value string="2012/12/15" />
</logItem>
<logItem type="error">
<value string="File not...
December 11, 2012 at 9:14 am
No problem....thanks for the feedback
December 3, 2012 at 5:43 am
Hi,
I think the main thing that you was missing was the namespace declaration. I have also made a couple of minor alterations, namely the cross apply and removing the .query()...
December 1, 2012 at 4:47 am
Hi,
I would use the newer XML functions rather then the old OPENXML. Syntax wise you could probably do this in a couple of ways, but here is one that I...
November 30, 2012 at 8:07 am
In other words, as long as the xml document conforms to the XSD, you can have as many or as few nodes as necessary.
That is the crucial thing, as long...
November 27, 2012 at 12:55 pm
If i understand you correctly, you have an xml instance as a string which you want to assign directly to an xml variable whilst at the same time, populating some...
November 15, 2012 at 2:20 pm
grovelli-262555 (11/2/2012)
Are there any books that explain syntax such as $x or //EXPR?
Hi grovelli,
$x is a variable within a flwor statement. You can begin to learn about flwor statements...
November 6, 2012 at 11:19 am
Jeff Moden (10/31/2012)
Nice job, Arthur.No reflection on your fine code. Just an observation about XML. I'm absolutely amazed at how expensive this type of XML processing actually is.
Hi...
November 1, 2012 at 9:26 am
Viewing 15 posts - 61 through 75 (of 140 total)