store select query result in variable sql server

Solutions on MaxInterview for store select query result in variable sql server by the best coders in the world

showing results for - "store select query result in variable sql server"
Safiya
25 Aug 2017
1DECLARE @result1 TABLE (a INT, b INT, c INT)
2
3INSERT INTO @result1
4SELECT a, b, c
5FROM table1
6
7SELECT a AS val FROM @result1
8UNION
9SELECT b AS val FROM @result1
10UNION
11SELECT c AS val FROM @result1
12