Advertisement
krot

WHILE FUNCTION

Mar 20th, 2018
259
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 0.33 KB | None | 0 0
  1. CREATE FUNCTION [dbo].[inc] (@forLimit int)  
  2. RETURNS @Ints TABLE
  3. (  
  4.   value int PRIMARY KEY
  5. )  
  6. AS  
  7. BEGIN  
  8. DECLARE @index int
  9.     SET @index = 0
  10.      
  11.     WHILE @index <= @forLimit BEGIN
  12.           INSERT INTO @Ints VALUES (@index)
  13.           SET @index = @index + 1
  14.     END
  15.     RETURN
  16. END;
  17.  
  18.  SELECT * FROM group_set g
  19.  Cross apply inc( 1) u
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement