Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
aoriju
Posting Yak Master
156 Posts |
Posted - 2012-09-20 : 06:18:39
|
| DECLARE @tblA AS TABLE(col1 VARCHAR(20), col2 VARCHAR(20) )DECLARE @tblB AS TABLE(col1 VARCHAR(20) )INSERT INTO @tblA SELECT 'A1' ,'A'INSERT INTO @tblA SELECT 'A2' ,'A'INSERT INTO @tblA SELECT 'B1' ,'B'INSERT INTO @tblA SELECT 'B2' ,'B'INSERT INTO @tblB SELECT 'A'INSERT INTO @tblB SELECT 'A'INSERT INTO @tblB SELECT 'A'INSERT INTO @tblB SELECT 'B'INSERT INTO @tblB SELECT 'B'While joining the @tblA col2 with @tblB col1 then i need to get values likeA1B1that means after joins 1 record only(Top 1) |
|
|
senthil_nagore
Master Smack Fu Yak Hacker
1007 Posts |
Posted - 2012-09-20 : 06:37:34
|
| Do you need this? select distinct a.col2 from @tblA a inner join @tblB bon a.col2 =b.col1Senthil Kumar C------------------------------------------------------MCITP - Database Administration SQL SERVER 2008MCTS - Database Development SQL SERVER 2008 |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2012-09-20 : 06:40:02
|
TOP 1 of ?maybe like this ?select MIN(col1)from @tblAgroup by col2 KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
|
|
|