SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 MS SQL: Is It Possible? One column, multiple value
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

aitaiaitai
Starting Member

3 Posts

Posted - 05/27/2012 :  21:06:56  Show Profile  Reply with Quote
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)

Singapore
16746 Posts

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


KH
Time is always against us

Go to Top of Page

aitaiaitai
Starting Member

3 Posts

Posted - 05/27/2012 :  21:23:13  Show Profile  Reply with Quote
Thanks for response, khtan.

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

khtan
In (Som, Ni, Yak)

Singapore
16746 Posts

Posted - 05/27/2012 :  21:27:04  Show Profile  Reply with Quote

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'



KH
Time is always against us

Go to Top of Page

aitaiaitai
Starting Member

3 Posts

Posted - 05/27/2012 :  21:35:25  Show Profile  Reply with Quote
That did the trick - Much appreciated, khtan!
Go to Top of Page

khtan
In (Som, Ni, Yak)

Singapore
16746 Posts

Posted - 05/27/2012 :  21:45:27  Show Profile  Reply with Quote
welcome


KH
Time is always against us

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000