create table #tbl1(a nvarchar(max)) insert into #tbl1 va...

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(a nvarchar(max))
insert into  #tbl1 values
('1'),('2'),('3'),('4')
 
 
 
create table #tbl2(a nvarchar(max))
insert into  #tbl2 values
('a'),('b'),('c'),('d')


--select * from(
select * ,row_number() over 
(partition by #tbl1.a order by #tbl2.a) as rn  from #tbl1,#tbl2 
--)d where d.rn=1

--SELECT unique_ID , s.f FROM #tbl1 cross apply(select top  1 unique_ID as f from #tbl2) s

Enter Parameters

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