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:08:59
|
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 |
|
gbritton
Master Smack Fu Yak Hacker
2780 Posts |
Posted - 2015-01-02 : 10:05:16
|
you have to from clauses in your query. That is invalid syntax. What you want is to change the join a little bit. Change it to: join #temp as b |
|
|
|
|
|