The table includes a DATETIME column named EventTime that stores the date and time of each Event. There is a non-clustered index on the EventTime column. To create a report that displays the total number of events happened on the current day, You need to write a query that will return the correct results in the most efficient manner. Which T-SQL query should you use?

 Posted by Bandi on 8/29/2017 | Category: Sql Server Interview questions | Views: 1336 | Points: 40
Select from following answers:
  1. SELECT COUNT(*) FROM Events WHERE EventTime >= CONVERT(DATE, GETDATE()) AND EventTime < DATEADD(DAY, 1, CONVERT(DATE, GETDATE()))
  2. SELECT COUNT(*) FROM Events WHERE EventTime = CONVERT(DATE, GETDATE())
  3. SELECT COUNT(*) FROM Events WHERE EventTime = GETDATE()
  4. SELECT COUNT(*) FROM Events WHERE CONVERT(VARCHAR, EventTime, 112) = CONVERT(VARCHAR, GETDATE(), 112)
  5. All Above

Show Correct Answer


| Alert Moderator 

Comments or Responses

Login to post response