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 |
summer12in
Starting Member
6 Posts |
Posted - 2015-01-01 : 23:04:22
|
I found something very strange...stufff function working with self join but not working with left or right join,.I have a table **Id name**1 samar1 Harry2 jackI want the output as **Id name**1 samar Harry2 jackThe below query works fine with self join Select b.id, stuff ((select ` ` + a.name from #test a where a.id = b.id for xml path (``)),1,1,``) From #test b Group by idBut when i do right join i get error _ invalid object name `b`. Please let me know where i am going wrong.... Select b.id, stuff ((select ` ` + a.name from #test a right join b on b.id = a.id for xml path (``),1,1,``) From #test b Group by idSamarjeet |
|
ahmeds08
Aged Yak Warrior
737 Posts |
Posted - 2015-01-01 : 23:32:02
|
Select b.id,stuff ((select ` ` + a.name from #test a right join #test b on b.id = a.id for xml path (``),1,1,``)Group by idJaveed Ahmedhttps://www.linkedin.com/pub/javeed-ahmed/25/5b/95 |
|
|
summer12in
Starting Member
6 Posts |
Posted - 2015-01-01 : 23:40:50
|
But the b table is already defined in the outer query..and the same logic is used in the first query which is working fineSamarjeet |
|
|
ahmeds08
Aged Yak Warrior
737 Posts |
Posted - 2015-01-01 : 23:54:06
|
did you try my query?Javeed Ahmedhttps://www.linkedin.com/pub/javeed-ahmed/25/5b/95 |
|
|
summer12in
Starting Member
6 Posts |
Posted - 2015-01-02 : 02:26:56
|
Yes.. its giving error as The multi part identifier b.idi could not be foundSamarjeet |
|
|
|
|
|
|
|