SELECT TOP(DATEDIFF(DAY, R.CheckIn, R.CheckOut))

SELECT TOP(DATEDIFF(DAY, R.CheckIn, R.CheckOut)+1)

SET STATISTICS TIME ON;WITH R AS (SELECT 1 AS N UNION ALL SELECT R.N + 1 FROM R WHERE R.N <= 4000)SELECT * INTO #bucket FROM R OPTION (MAXRECURSION 0)SET STATISTICS TIME OFF;