PrepAway - Latest Free Exam Questions & Answers

Which Transact-SQL query should you use?

Your database contains a table named Purchases. The table includes a DATETIME column named PurchaseTime that stores the date and time each purchase is

made. There is a non- clustered index on the PurchaseTime column. The business team wants a report that displays the total number of purchases made on the
current day. You need to write a query that will return the correct results in the most efficient manner.
Which Transact-SQL query should you use?

PrepAway - Latest Free Exam Questions & Answers

A.
SELECT COUNT(*)
FROM Purchases
WHERE PurchaseTime = CONVERT(DATE, GETDATE())

B.
SELECT COUNT(*)
FROM Purchases
WHERE PurchaseTime = GETDATE()

C.
SELECT COUNT(*)
FROM Purchases
WHERE CONVERT(VARCHAR, PurchaseTime, 112) = CONVERT(VARCHAR, GETDATE(), 112)

D.
SELECT COUNT(*)
FROM Purchases
WHERE PurchaseTime >= CONVERT(DATE, GETDATE())
AND PurchaseTime <DATEADD(DAY, 1, CONVERT(DATE, GETDATE()))

Explanation:
http://technet.microsoft.com/en-us/library/ms181034.aspx

5 Comments on “Which Transact-SQL query should you use?

  1. ena says:

    these are the questions for 70-462: Administering Microsoft SQL Server 2012/2014 Databases.

    70-765 is about azure mainly, so most if not all of these questions are not even about the subject matter.

    ps: stil props to the guys running this site though, got me through sql 2012/14 with ease 🙂




    0



    0

Leave a Reply