Is there a quick / efficient way to check if a table is empty?
DECLARE @StartEndTimes TABLE ( id bigint, StartTime datetime, EndTime datetime ) IF @StartEndTimes IS NOT NULL
Instead of counting, you can:
if exists (select id from @StartEndTimes) set @has_stuff = 1
which will return as soon as it hits the string.
I think your best bet might be COUNT
DECLARE @StartEndTimes TABLE ( id bigint, StartTime datetime, EndTime datetime ) SELECT COUNT(1) FROM @StartEndTimes