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

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

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