Write A Query To Print 1 To 100 In SQL Server Using Without Loop

In this blog, we will print 1 to 100 numbers in SQL Server without using while loop.

We will write very simple query. Do not worry about how will I write without loop.
  1. with CTE as  
  2. (  
  3.  select 1 Number  
  4.  union all  
  5.  select Number +1 from CTE where Number<100  
  6. )  
  8. select *from CTE  

Increment of number in a variable will always be 1, while loop iterates 100 times and print the numbers easily.