Querying Data with Transact-SQL — Question 50
You have a date related query that would benefit from an indexed view.
You need to create the indexed view.
Which two Transact-SQL functions can you use? Each correct answer presents a complete solution.
NOTE: Each correct selection is worth one point.
Answer options
- A. DATEADD
- B. AT TIME ZONE
- C. GETUTCDATE
- D. DATEDIFF
Correct answer: C, D
Explanation
The correct answers are C and D because GETUTCDATE provides the current UTC date and time, while DATEDIFF calculates the difference between two dates, both of which can be utilized in an indexed view. Options A and B, DATEADD and AT TIME ZONE, are not valid for creating indexed views due to their nature of altering or formatting dates rather than providing a direct date calculation.