I'm trying to write an error handling query using the TRY...CATCH construct as a homework problem. I want to compare today's day to a variable @CurrentDay equal to a day of 24 and have it fail out of the TRY construct to the CATCH construct and print a message indicating the actual day.
Is it possible to make my query work? If it is, what changes do I need to make my query work?
DECLARE @CurrentDay AS INT = 24;
SELECT @CurrentDay = DAY(CURRENT_TIMESTAMP)
PRINT 'Today is the 24th day of the month';
PRINT 'Today is day number ' + DAY(CURRENT_TIMESTAMP) + ' of the month';