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)
 MS SQL: Is It Possible? One column, multiple value

Author  Topic 

aitaiaitai
Starting Member

3 Posts

Posted - 2012-05-27 : 21:06:56
In MS SQL (2008), is it possible to return multiple values from a single column in a single row with the following subquery?

-----
select dic_kanji_primary,dic_previous_jis,dic_etymology_1,
(
select dio_reading
from tbl_dictionary_on
where dic_id_pk = dio_id_fpk
) as dio_reading
from tbl_dictionary_kanji
where 1=1
and dic_ecu_indicator='1'
-----

The "dio_reading" column in the subquery should return multiple values.

Any help will would be greatly appreciated - Thanks in advance!

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2012-05-27 : 21:14:04
see http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=81254


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

aitaiaitai
Starting Member

3 Posts

Posted - 2012-05-27 : 21:23:13
Thanks for response, khtan.

Not sure what I should be looking at though...
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2012-05-27 : 21:27:04
[code]
select dic_kanji_primary,dic_previous_jis,dic_etymology_1,
stuff(
(
select ',' + dio_reading
from tbl_dictionary_on
where dic_id_pk = dio_id_fpk
for xml path('')

),
1, 1, '') as dio_reading
from tbl_dictionary_kanji
where 1=1
and dic_ecu_indicator='1'
[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

aitaiaitai
Starting Member

3 Posts

Posted - 2012-05-27 : 21:35:25
That did the trick - Much appreciated, khtan!
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2012-05-27 : 21:45:27
welcome


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -