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)
 comma separated values

Author  Topic 

kiranmurali
Yak Posting Veteran

55 Posts

Posted - 2010-08-26 : 13:25:22
i have a senario as below:

in my userdefined table the col values are stored as below

locid '2,4,5,6'

for these values i have to get the related names from the master table as 'kirthi,lekha,sneha,vijay' like this.

can you help me how to solve this?

Thanks in advance
kiranmurali

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-08-26 : 13:54:46
Please post your table structure and sample data.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

kiranmurali
Yak Posting Veteran

55 Posts

Posted - 2010-08-27 : 01:53:13
[quote]Originally posted by tkizer

Please post your table structure and sample data.

This is my master table structure
fieldname datatype
seskey int pk
locname varchar(100)
shortname varchar(3)
del_flag int default 0

sample data
1 BANGALORE BNG O
2 CHENNAI CHN 0
3 HYDERABAD HYD 0

This is my userdefined table

structure
id int pk
group_name varchar(100)
short_name varchar(3)
locid varchar(max)
address varchar(250)
profile varchar(250)

sample data
1 tata tat (1,2,3) xyz abc
2 tatasteel tas (2,4) xyz abc
3 mindtree mnd (1,4) xyz abc

In one situation i have to get for (1,2,3) the corresponding
values(bangalore,chennai,hyderabad)as the output
give me some suggestions to solve this.

thanks in advance
kiranmurali
Go to Top of Page
   

- Advertisement -