You work as a database administrator at ABC.com. ABC.com has a SQL Server 2012 database
named ProductsDB. The ProductsDB database is shown in the following database diagram:
You need to write a Transact-SQL query that displays all the products received by a single
supplier in the following XML format:
<Suppliers SupplierID=”22″ Company=”Company Name” ContactNumber=”510 250 6400″>
<Products ProductID=”100″ UnitPrice=”249.00″ UnitsInStock=”7″ />
<Products ProductID=”118″ UnitPrice=”559.00″ UnitsInStock=”12″ />
</Suppliers>
Which of the following SELECT statement would you write?
A.
SELECT s.SupplierID, s.CompanyName AS [Company], s.ContactNumber, p.ProductID,
p.UnitPrice, p.UnitsInStock
FROM Suppliers AS s
INNER JOIN Products AS p ON s.SupplierID = p.SupplierID
WHERE s.SupplierID = 22
FOR XML RAW
B.
SELECT s.SupplierID, s.CompanyName AS [Company], s.ContactNumber, p.ProductID,
p.UnitPrice, p.UnitsInStock
FROM Suppliers AS s
INNER JOIN Products AS p ON s.SupplierID = p.SupplierID
WHERE s.SupplierID = 22
FOR XML
C.
SELECT Suppliers.SupplierID, Suppliers.CompanyName AS [Company],
Suppliers.ContactNumber, Products.ProductID, Products.UnitPrice, Products.UnitsInStock
FROM Suppliers
INNER JOIN Products ON Suppliers.SupplierID = Products.SupplierID
WHERE Suppliers.SupplierID = 22
FOR XML AUTO
D.
SELECT Suppliers.SupplierID, Suppliers.CompanyName AS [Company],
Suppliers.ContactNumber, Products.ProductID, Products.UnitPrice, Products.UnitsInStock
FROM Suppliers
INNER JOIN Products ON Suppliers.SupplierID = Products.SupplierID
WHERE Suppliers.SupplierID = 22
FOR XML AUTO, RAW
Explanation: