PrepAway - Latest Free Exam Questions & Answers

Which code segment should you use?

CORRECT TEXT
You have a view that was created by using the following code:

You need to create an inline table-valued function named Sales.fn_OrdersByTerritory, which must
meet the following requirements:
Accept the @T integer parameter.
Use one-part names to reference columns.
Filter the query results by SalesTerritoryID.
Return the columns in the same order as the order used in OrdersByTerritoryView.
Which code segment should you use?
To answer, type the correct code in the answer area.

PrepAway - Latest Free Exam Questions & Answers

Answer: See the explanation

Explanation:
CREATE FUNCTION Sales.fn_OrdersByTerritory (@T int)
RETURNS TABLE
AS
RETURN
(
SELECT OrderID,OrderDate,SalesTerrirotyID,TotalDue
FROM Sales.OrdersByTerritory
WHERE SalesTerritoryID = @T
)

6 Comments on “Which code segment should you use?

  1. Mokrane says:

    create function Sales.fn_OrdersByTerritory (@t int) as
    returns table
    as return
    (select orderID,Orderdate,SalesTerritoryID,TotalDue
    from Sales.ordersByTerritory
    where SalesTerritoryID =@T)




    0



    0
    1. Matilda says:

      Your answer has an error: the ‘create function Sales.fn_OrdersByTerritory (@t int) as’ does not have the ‘as’.
      Should be:
      create function Sales.fn_OrdersByTerritory (@T int)
      returns table
      as return
      (select orderID,Orderdate,SalesTerritoryID,TotalDue
      from Sales.ordersByTerritory
      where SalesTerritoryID =@T)




      0



      0
  2. Bob says:

    CREATE FUNCTION Sales.fn_OrdersByTerritory (@T int)
    RETURNS TABLE
    AS
    RETURN
    (
    SELECT OrderID,OrderDate,SalesTerrirotyID,TotalDue
    FROM Sales.OrdersByTerritory
    WHERE SalesTerritoryID = @T
    )




    0



    0
  3. lewis says:

    create function Sales.fn_OrderByTerritory (@T int)
    returns table
    as
    return
    (
    select OrderID,OrderDate,SalesTerritoryID,TotalDue
    from Sales.OrdersByTerritory
    where SalesTerritotyID = @T
    )




    0



    0
  4. IG says:

    CREATE FUNCTION Sales.fn_OrdersByTerritory (
    @stid int

    )
    RETURNS TABLE
    AS
    RETURN

    SELECT orderid, orderdate, salesterritoryid, totaldue

    FROM Sales.ordersbyterritory
    WHERE SalesTerritoryID = @stid




    0



    0

Leave a Reply