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 |
|
ArpitNarula
Starting Member
16 Posts |
Posted - 2011-01-31 : 23:30:38
|
| Hi Guys,Below is the scenerio:Table A id name parent id1 a 22 b 33 c null4 d 35 e 1 Need output like: name parent name a b b c c Null d c e a Thanks in advance. |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2011-02-01 : 01:28:05
|
SELECT t2.Name, t1.Name AS ParentNameFROM dbo.TableA AS t1INNER JOIN dbo.TableA AS t2 ON t2.ID = t1.ParentID N 56°04'39.26"E 12°55'05.63" |
 |
|
|
MIK_2008
Master Smack Fu Yak Hacker
1054 Posts |
Posted - 2011-02-01 : 01:37:03
|
| Perhaps this would give the desired outputSELECT t1.Name,t2.Name as parentNameFROM @TableA AS t1Left JOIN @TableA AS t2 ON t1.ParentID = t2.ID |
 |
|
|
|
|
|