Don't forget that SQL server can work as your simple calculator or runtime environment to test out small pieces of code.
As calculator:
print 135 * 3.24
Prints:
437.40
Or figuring out if your idea of calculating factorial is ok:
declare @l int
set @l = 0
while @l <= 100
begin
declare @res float
set @res = 1.0
declare @i int
set @i = 1
while @i <= @l
begin
set @res = @res * @i
set @i = @i + 1
end
print str(@l)+'! = ' + convert(varchar(50),@res)
set @l = @l + 1
end
Prints:
0! = 1
1! = 1
2! = 2
3! = 6
4! = 24
5! = 120
...
Inga kommentarer:
Skicka en kommentar