Here this script is displying Fibonacci Series from 1 to 1000.
declare @a int
declare @b int
declare @c int
declare @res varchar(200)
set @a = 0
set @b = 1
set @c = 0
set @res = ' '
while(@c<=1000)
begin
set @a = @b
Set @b = @c
set @c = @a + @b
set @res = @res + cast(@c as varchar) + ','
end
print reverse(substring(reverse(@res),2,len(@res)))
Output will be...
1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987,1597
About Me
-
Anil Desai.
Software Engineer
T M Technologies
જય વાળીનાથ - T-SQL is a basic of structure query language. So I always want to learn T-SQL in different way to get best performance in query. And its my passion.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment