krot

WHILE FUNCTION

Mar 20th, 2018
89
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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
RAW Paste Data