Kevin,

I know you asked this as another post, but this is possible with UDFs for most 
databases.

create function dbo.get_list(
    @table_name varchar(128)
)
returns varchar(8000) as
begin
    declare @t varchar(8000)
    
    set @t = ''
    
    select
        @t = @t + c.COLUMN_NAME + ', '
    from
        INFORMATION_SCHEMA.COLUMNS c
    where
        c.TABLE_NAME = @table_name
    order by
        c.ORDINAL_POSITION desc
    
    return case when datalength(@t) < 2 then @t else substring(@t, 1, 
datalength(@t) - 2) 
end
end
go

-- then to test this
select
    t.table_name, dbo.get_list(t.table_name) column_list
from
    information_schema.tables t


-- 
David L. Penton, Microsoft MVP
JCPenney Application Specialist - Lead
"Mathematics is music for the mind, and Music is Mathematics for the
Soul. - J.S. Bach"
Blog @ http://blogs.SqlAdvice.com/dpenton/

Do you have SQL BOL installed?  If not, why not?
New SP3 SQL BOL: http://www.davidpenton.com/sqlbol

---------- Original Message -----------
From: "Kevin Fricke" <[EMAIL PROTECTED]>
To: "CFLIST" <[email protected]>
Sent: Mon, 5 Dec 2005 10:49:02 -0600
Subject: [DFW CFUG] queries

> How do I pull a list of values into one column of a query result?  Is this
> possible?
> 
> For example, I have a list of reservations.  With each reservation there may
> be a number of food options selected.
> 
> Is it possible to run a query which will return the following results?
> 
> ID | Client Name | Food 1,Food2,Food3 | etc.
> 
> Kevin
> 
> _______________________________________________
> List mailing list
> Reply to DFWCFUG: 
> [email protected]
> Subscribe/Unsubscribe: 
> http://lists1.safesecureweb.com/mailman/listinfo/list
> List Archive: 
> http://lists1.safesecureweb.com/mailman/private/list
> DFWCFUG Sponsors: www.HostMySite.com www.teksystems.com/
------- End of Original Message -------


_______________________________________________
List mailing list
Reply to DFWCFUG: 
[email protected]
Subscribe/Unsubscribe: 
http://lists1.safesecureweb.com/mailman/listinfo/list
List Archive: 
http://lists1.safesecureweb.com/mailman/private/list
DFWCFUG Sponsors: www.HostMySite.com www.teksystems.com/

Reply via email to