create table #tbl1(cola nvarchar(max)) insert into #tbl1...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

create table #tbl1(cola nvarchar(max))
insert into  #tbl1 values
('1'),('2'),('3'),('4')
 
 
 
create table #tbl2(colb nvarchar(max))
insert into  #tbl2 values
('a'),('b'),('c'),('d')


 
 
;WITH
a1 AS (SELECT cola, ROW_NUMBER() OVER (ORDER BY cola) AS rn1 FROM #tbl1),
a2 AS(SELECT colb, ROW_NUMBER() OVER (ORDER BY colb) AS rn2 FROM #tbl2)
SELECT a1.cola, a2.colb
FROM a1
JOIN a2 on a1.rn1=a2.rn2;

Enter Parameters

Options:
Switch to meta site
loading Hold tight while we fetch your results