if isnull(object_id('tempdb..##rowtest'),0) <> 0 drop table ##rowtestselect top 100 identity(int,1,1) idkey into ##rowtest from syscolumnsselect idkey, case when idkey % 3 = 0 then 'Fizz' else '' end [fizz], case when idkey % 5 = 0 then 'Buzz' else '' end [buzz], case when idkey%3 = 0 and idkey%5 = 0 then 'FizzBuzz' else '' end [fizzbuzz]from ##rowtest
;WITH Nbrs(n) AS( SELECT 1 UNION ALL SELECT 1 + n FROM Nbrs WHERE n < 100)SELECT CASE WHEN n%5=0 AND n%3=0 THEN 'BizzBuzz' WHEN n%3 = 0 THEN 'Bizz' WHEN n%5 = 0 THEN 'Buzz' ELSE CAST(n AS VARCHAR(8)) ENDFROM NbrsOPTION (MAXRECURSION 100);