Took me about 5 minutes to do. I did have a few small issues in my code at first though.
Here’s what I came up with:
declare @t table (
declare @i int
set @i = 1
while @i <= 100
insert into @t
set @i = @i+1
when convert(int,num)%3 = 0 and convert(int,num)%5 = 0 then 'FizzBuzz'
when convert(int,num)%3 = 0 then 'Fizz'
when convert(int,num)%5 = 0 then 'Buzz'
The first time I did this, I made num an int because I wanted just numbers in my numbers table. This would have proven to be more difficult in the conversion of a varchar to an int. The easier way was to do the conversion on case statement.
Is this the best way to do this? No idea. BUT…it works.