PrepAway - Latest Free Exam Questions & Answers

Which four T-SQL statements should you use?

DRAG DROP
You use a Microsoft SQL Server 2012 database. You need to create an indexed view within
the database for a report that displays Customer Name and the total revenue for that customer.
Which four T-SQL statements should you use? (To answer, move the appropriate SQL
statements from the list of statements to the answer area and arrange them in the correct order.)

PrepAway - Latest Free Exam Questions & Answers

Answer:

Explanation:
http://msdn.microsoft.com/en-us/library/ms191432.aspx

4 Comments on “Which four T-SQL statements should you use?

  1. Slazenjer_m says:

    You are both wrong. Agreed that the first index should be clustered, but the syntax for a clustered index MUST reference at least TWO column-names in the index definition (CustomerID, CustomerName). When the index would reference only ONE column (in this case, CustomerID), there can only be a unique (non-clustered) index; hence the selected option is the right one.




    0



    0
  2. Slazenjer_m says:

    –Create view with schemabinding
    IF OBJECT_ID (‘Sales.vOrders’, ‘view’) IS NOT NULL
    DROP VIEW Sales.vOrders;
    GO

    CREATE VIEW Sales.vOrders
    WITH SCHEMABINDING
    AS
    SELECT SUM(UnitPrice*OrderQty*(1.00-UnitPriceDiscount)) AS Revenue,
    OrderDate, ProductID, COUNT_BIG(*) AS COUNT
    FROM Sales.SalesOrderDetail AS od, Sales.SalesOrderHeader AS o
    WHERE od.SalesOrderID = o.SalesOrderID
    GROUP BY OrderDate, ProductID;
    GO

    –Create an index on the view
    CREATE UNIQUE CLUSTERED INDEX IDX_V1
    ON Sales.vOrders (OrderDate, ProductID);
    GO




    0



    0

Leave a Reply