Session Ready
Exercise

Test type-safe conversion function performance

In the last two exercises, we looked at the TRY_CAST(), TRY_CONVERT(), and TRY_PARSE() functions. These functions do not all perform equally well. In this exercise, you will run a performance test against all of the dates in our calendar table.

To make it easier, we have pre-loaded dates in the dbo.Calendar table into a temp table called DateText, where there is a single NVARCHAR(50) column called DateText.

For the first three steps, the instructions will be the same: fill in missing values to complete the relevant function call. After doing that, observe the amount of time each operation takes and keep the results in mind. You will then summarize your results in step 4.

Instructions 1/4
undefined XP
  • 1
  • 2
  • 3
  • 4
  • Fill in the correct conversion function based on its parameter signature.
  • Note the amount of time returned in the DATEDIFF() call.
  • Do not use @StartTimeCast or @EndTimeCast in your answer; these are for calculating execution time.