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.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 MULTIPLE VALUES

Author  Topic 

Arun.G
Yak Posting Veteran

81 Posts

Posted - 2010-05-26 : 05:52:36
SAMPLE DATA IN MY TABLE:



EMPID NAME POSITION ROLEID
1 AAA MGR 2,3
2 BBB TRA 3
3 CCC EMP 4


NOW I WANT THE RESULT LIKE:

EMPID NAME ROLES
1 AAA FUNHEAD, ADMIN
2 BBB ADMIN
3 CCC HR


INSTEAD OF ROLEID I WANT TO DISPLAY ROLENAME AND THE VALUES SHOULD BE SEPAERATED BY COMMA

THE ROLES ARE COMING FROM MASTER TABLE WHICH CONTAINS ROLEID AND ROLENAME


PLS HELP ME TO SOLVE THIS IN QUERY IMMEDIATELY

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-05-26 : 05:56:03
To get the ROLENAME you have to join the MASTER TABLE on ROLEID.
The comma separated display should really be done in the front end.


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-05-26 : 06:06:23
Also you need to read about normalization

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -