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')


 
 
 --working :
 ------------
 /*SELECT table1.cola, table2.colb FROM
(SELECT cola, ROW_NUMBER() OVER (ORDER BY cola) AS rn1 FROM #tbl1) table1,
(SELECT colb, ROW_NUMBER() OVER (ORDER BY colb) AS rn2 FROM #tbl2) table2
WHERE table1.rn1 = table2.rn2*/


SELECT cola , s.f FROM #tbl1 cross apply(select   colb as f from #tbl2) s

Enter Parameters

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