Which query should you use?

You are a database developer on an instance of SQL Server. You have defined an inline table-valued function using the following statement:
CREATE FUNCTION udf_GetOrderDetails (@OrderID int)
RETURNS TABLE
AS
RETURN (
SELECT sh.OrderDate, sd.*
FROM SalesOrderHeader sh
INNER JOIN SalesOrderDetail sd
ON sh.SalesOrderID = sd.SalesOrderID
WHERE sd.SalesOrderID = @OrderID);
You have table named SalesOrderHistory that contains a SalesOrderID column. You want to query the SalesOrderHistory table and use the udf_GetOrderDetails function to return order details. All sales orders in the SalesOrderHistory table and the associated order details should be displayed, even if no details exist for a given order.
Which query should you use?
A. SELECT * FROM
FROM SalesOrderHistory h
CROSS APPLY udf_GetOrderDetails (h.SalesOrderID) AS d
B. SELECT h.*, d.*FROM SalesOrderHistory h
OUTER APPLY udf_GetOrderDetails (h.SalesOrderID) AS d ORDER BY h.SalesOrderID;
C. SELECT * FROM udf_GetOrderDetails(t.SalesOrderID)) as t;
D. SELECT h.*, d.*
INNER JOIN udf_GetOrderDetails(h.SalesOrderID) AS d
ON h.SalesOrderID = d.SalesOrderID
ORDER BY h.SalesOrderID;

microsoft-exams

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.