Yup, this is the baby (SQL Server mind!)

<cfquery name="getColumns" datasource="#attributes.datasource#">
        SELECT sc.name as 'columnName', st.name as 'dataType'
        FROM sysobjects so, syscolumns sc, systypes st 
        WHERE so.name=<cfoutput>'#attributes.tablename#'</cfoutput> 
        AND so.xtype='U'
        AND so.id = sc.id
        AND sc.xtype = st.xtype
        AND so.status > 0
        ORDER BY sc.name
</cfquery>

Check out the schema for sysobjects - you should be able to access more info than just 
the name & datatype as above.

HTH

Steve


> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Sent: 17 July 2003 11:39
> To: [EMAIL PROTECTED]
> Subject: RE: [ cf-dev ] Would this work?
> 
> 
> Thanks, one further follow up question, is there a way that I 
> can then get
> the datatype of the columns and other bits of info (max size 
> for a string
> etc?)
> 
> Cheers,
> 
> CHris
> 
> > -----Original Message-----
> > From: Adrian Lynch [mailto:[EMAIL PROTECTED]
> > Sent: 17 July 2003 11:42
> > To: '[EMAIL PROTECTED]'
> > Subject: RE: [ cf-dev ] Would this work?
> > 
> > 
> > No reason why it wouldn't work.
> > 
> > queryName.ColumnList will return the columns of a table as a 
> > comma separated
> > list, loop through it and use it as you will
> > 
> > Ade
> > 
> > -----Original Message-----
> > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> > Sent: 17 July 2003 11:35
> > To: [EMAIL PROTECTED]
> > Subject: [ cf-dev ] Would this work?
> > 
> > 
> > Hi,
> > 
> > Am at the design stage for a site, and am wondering if the 
> > following would
> > work:
> > 
> > <cfquery name="name" datasource="datasource">
> >     SELECT  *
> >     FROM            TABLE
> >     WHERE   #THE_FIELD#=#THE_VALUE#
> > </cfquery>
> > 
> > Also is there a way that I can loop through all of the Fields 
> > in a table
> > (ie. if i have a table called USERS I want to loop using the 
> > name of each
> > field (ie. USER_LOGIN, USER_FORENAMES...).
> > 
> > Cheers,
> > 
> > Chris Cormack
> > 
> > British Telecommunications plc
> > Registered office: 81 Newgate Street London EC1A 7AJ
> > Registered in England no. 1800000
> > This electronic message contains information from British 
> > Telecommunications
> > plc which may be privileged or confidential. The information 
> > is intended to
> > be for the use of the individual(s) or entity named above. If 
> > you are not
> > the intended recipient be aware that any disclosure, copying, 
> > distribution
> > or use of the contents of this information is prohibited. 
> If you have
> > received this electronic message in error, please notify us 
> > by telephone or
> > email (to the numbers or address above) immediately. 
> > Activity and use of the British Telecommunications plc E-mail 
> > system is
> > monitored to secure its effective operation and for other 
> > lawful business
> > purposes. Communications using this system will also be 
> > monitored and may be
> > recorded to secure effective operation and for other lawful business
> > purposes. 
> > Any views expressed in this email do not reflect those of BT 
> > and any of
> > partners and assosiates. Responsiblity for the opinions 
> > expressed are those
> > of the sender only
> > 
> > 
> > -- 
> > ** Archive: 
http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/
> 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> For human help, e-mail: [EMAIL PROTECTED]
> 
> -- 
> ** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/
> 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> For human help, e-mail: [EMAIL PROTECTED]
> 
> 

-- 
** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/

To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
For human help, e-mail: [EMAIL PROTECTED]


--
** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/

To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
For human help, e-mail: [EMAIL PROTECTED]

Reply via email to