> How do  you output the names of the fields of a table
> from SQL server and their values when you don't know
> the names of the fields or the values of those fields.
> Can you just have a query like:
>
> <cfquery name="GetTableData" datasource="#MyDatasource#">
>     select *
>     from ThatTable
> </cfquery>

Use GetTableData.ColumnList, this gives a comma separates list of the
fields.

BTW, doing "select *" is very slow compared to naming the fields, as the
database has to grab the field names before it can run the query.

If you're using SQL Server, then you can get the real column names by;
        select Column_Name from Information_Schema.Columns
        where Table_Name='myTable'

Information_Schema.Columns also gives you Data_Type,
Character_Maximum_Length, Is_Nullable, Numeric_Precision, and much more

If you really know nothing about the table, you can find an awful lot from
SQL Server just by querying the right built-in views

BTW, if you want to find the Primary Key, then;
        select o.name as oName, c.name as cName from syscolumns c, sysobjects o
        where c.id=o.id and (c.status & 128)=128 and o.name='myTable'

oName will be the table name, cName will be the column name

HTH

Philip Arnold
ASP Multimedia Limited
T: +44 (0)20 8680 1133

"Websites for the real world"

**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.
**********************************************************************


------------------------------------------------------------------------------
Archives: http://www.eGroups.com/list/cf-talk
To Unsubscribe visit 
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a 
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.

Reply via email to