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)
 to get multiple values

Author  Topic 

Arun.G
Yak Posting Veteran

81 Posts

Posted - 2010-05-25 : 10:18:26
I have one master table which contains dat

for example: Tableroles

roleid roles
1 trainee
2 leader
3 supervisor

etc,

Now I have another table: Tableprofile
ex:
prid name designation roles
1 aaa uuu 1,2

In role column i want to get the multiple roles for one person and also want to store that id of roles only, but in front end i have option to select only rolename from dropdown list, but in backend it should stored as id only

how to write query for this?

pk_bohra
Master Smack Fu Yak Hacker

1182 Posts

Posted - 2010-05-25 : 10:51:20
Can you provide table structure with some sample data so that we can understand your requirement in detail.
Go to Top of Page

vijayisonly
Master Smack Fu Yak Hacker

1836 Posts

Posted - 2010-05-25 : 11:21:21
quote:
Originally posted by Arun.G

I have one master table which contains dat

for example: Tableroles

roleid roles
1 trainee
2 leader
3 supervisor

etc,

Now I have another table: Tableprofile
ex:
prid name designation roles
1 aaa uuu 1,2

In role column i want to get the multiple roles for one person and also want to store that id of roles only, but in front end i have option to select only rolename from dropdown list, but in backend it should stored as id only

how to write query for this?




Why do you want to do this? This is not a good design to have all roles in a single row separated by commas.
Go to Top of Page

Arun.G
Yak Posting Veteran

81 Posts

Posted - 2010-05-26 : 01:34:55
As per our requirement ,Manager who is also one of the employee of organization should contain multiple roles, thats why, we want to store multiple roles for some employees by comma seperated values

for example: Tableprofile


SlNO Name Address Position Roles
1 aa tt Trainee 1
2 bb uu Employee 2
3 cc vv Manager 1,2,3
4 dd ww Trainee 1


Master Table:Roles

Roleid Roles
1 Tra
2 Emp
3 Admin


Now I want to display the result like below:

SlNO Name Roles
1 aa Tra
2 bb Emp
3 cc Tra,Emp,Admin
4 dd Tra


i want query for this issue
Go to Top of Page
   

- Advertisement -