chrisvenus: (Default)
[personal profile] chrisvenus
I'm in training at the moment on SQL server. I'm sulky at the moment too. Why? The trainer asked a question with what I thought was an obvious answer. I answered and was told I was wrong. Lots of other people answered and they were wrong too. When she told us the answer I discovered that I was actually right, she just hadn't quite understood what I said. This has made me sulky. On the other hand though I can be amused because I think I might understand this part of the course better than the trainer. Certainly soem of the explanations have been a little unclear in my mind.

Ah, well. Back to the training....

Edit:


The question was as follows (this is an abdridged version but keeps the core facts). For those that care I'm doing MS course 2779A.

I have the following XML:
<?xml version="1.0" ?>
<SalesInvoice InvoiceID="1000" CustomerID="123" OrderDate="2004-03-07">
   <Items>
      <Item ProductCode="12" Quantity="2" UnitPrice="12.99">aaa<ProductName>Bike</ProductName></Item>
      <Item ProductCode="41" Quantity="1" UnitPrice="17.45">bbb<ProductName>Helmet</ProductName></Item>
      <Item ProductCode="2" Quantity="1" UnitPrice="2.99">ccc<ProductName>Water Bottle</ProductName></Item>
   </Items>
</SalesInvoice>

I then do the following SQL:

SELECT * FROM 
OPENXML(@docHandle, '/SalesInvoice/Items/Item', 1)
WITH
	(InvoiceID int '../../@InvoiceID',
	ProductID int '@ProductCode',
	Quantity int 
)


Why do I not need to specify where Quantity gets its value from as I did for InvoiceID and ProductID?

Second edit: Explain in the above SQL what the '/SalesInvoice/Items/Item' means. The trainer did so *very* badly in my view and I want to see if those who know (probably Dave mainly) can explain better. :) Those who don't know are welcome to guess if they want. They are allowed to ask what the recordset returned looks like too if they want though.

(no subject)

Date: 2006-05-25 02:28 pm (UTC)
From: [identity profile] danfossydan.livejournal.com
You wanna know if I know the anwser.... well I have my SQL book infront of me somewhere... so I can look it up! AHAHAH! And you will never know!

(no subject)

Date: 2006-05-25 02:30 pm (UTC)
From: [identity profile] davedevil.livejournal.com
No I wanna know cos I teach SQL Server myself, what you know bothers me not :P

(ps I got Nine Worlds and it seems to be like a mage campaign)

Profile

chrisvenus: (Default)
chrisvenus

May 2011

S M T W T F S
1234567
891011121314
15161718192021
22232425262728
293031    

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags