how to use select union and loop

Solutions on MaxInterview for how to use select union and loop by the best coders in the world

showing results for - "how to use select union and loop"
Tim
23 Jan 2020
1CREATE TABLE #Temp
2(
3  <COLUMNS>
4)
5
6 DECLARE @position INT
7 SET @position = -1
8
9 WHILE(@position < 1)
10 BEGIN
11
12    INSERT INTO #Temp (<COLUMNS>)
13    SELECT * FROM mytable
14
15    SET @position = @position + 1
16
17 END
18
19 SELECT * FROM #Temp
20