Unix Technical Forum

Multiple values into single cell

This is a discussion on Multiple values into single cell within the SQL Server forums, part of the Microsoft SQL Server category; --> Taking the Northwind database as an example, I have an order table: 'Orders' a order details table: 'Order Details' ...


Go Back   Unix Technical Forum > Database Server Software > Microsoft SQL Server > SQL Server

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 03-01-2008, 03:06 PM
NAJH
 
Posts: n/a
Default Multiple values into single cell

Taking the Northwind database as an example,
I have an order table: 'Orders'
a order details table: 'Order Details'
and a products table: 'Products'

For reasons best ignored, I want to produce a query which has columns:

Orders.OrderID, Products


which has results like:

10248, 'Queso Cabrales, Singaporean Hokkien Fried Mee, Mozzarella di
Giovanni'
10249, 'Tofu, Manjimup Dried Apples'

________
so for those who don't really know what I'm on about and haven't got
access to northwind, I want the second cell to contain the returned
column of a second query (but in text format)

could anyone suggest a way this could be done? am I entering the land
of cursors?

Many thanks,
Neil

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 03-01-2008, 03:06 PM
Erland Sommarskog
 
Posts: n/a
Default Re: Multiple values into single cell

NAJH (neilonusenet@yahoo.co.uk) writes:
> For reasons best ignored, I want to produce a query which has columns:
>
> Orders.OrderID, Products
>
>
> which has results like:
>
> 10248, 'Queso Cabrales, Singaporean Hokkien Fried Mee, Mozzarella di
> Giovanni'
> 10249, 'Tofu, Manjimup Dried Apples'
>
> ________
> so for those who don't really know what I'm on about and haven't got
> access to northwind, I want the second cell to contain the returned
> column of a second query (but in text format)
>
> could anyone suggest a way this could be done? am I entering the land
> of cursors?


If you are on SQL 2000, yes. SQL Server MVP Anith Sen covers the various
methods on http://www.projectdmx.com/tsql/rowconcatenate.aspx.


--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 03-01-2008, 03:06 PM
--CELKO--
 
Posts: n/a
Default Re: Multiple values into single cell


>> For reasons best ignored, ... <<


Do not ignore the reasons; so, why do you want to write stinking bad
code?

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 03-01-2008, 03:06 PM
Ed Murphy
 
Posts: n/a
Default Re: Multiple values into single cell

--CELKO-- wrote:

>>> For reasons best ignored, ... <<

>
> Do not ignore the reasons; so, why do you want to write stinking bad
> code?


At least he isn't talking about storing the data that way, merely
outputting it that way. That said, I would do it in a separate
reporting layer (e.g. Crystal Reports) if at all possible.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 03-01-2008, 03:06 PM
NAJH
 
Posts: n/a
Default Re: Multiple values into single cell

On May 21, 3:27 am, Ed Murphy <emurph...@socal.rr.com> wrote:
> --CELKO-- wrote:
> >>> For reasons best ignored, ... <<

>
> > Do not ignore the reasons; so, why do you want to write stinking bad
> > code?

>
> At least he isn't talking about storing the data that way, merely
> outputting it that way. That said, I would do it in a separate
> reporting layer (e.g. Crystal Reports) if at all possible.


I know it's bad practice to do it that way and a seperate reporting
layer like crystal reports etc would be lovely, but I'm in a situation
where I don't have those kind of facilities and budgets at my
disposal. It's just a means to an end. I'm certainly not holding data
like that. It's bad enough dealing with internal politics without
having to deal with it again on here! Thanks to you all for your kind
(or not so kind) input.

Neil

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 06:34 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com