The Stored Procedure that Steve Onnis refers to gives you a query
containing heaps of info about the columns, including the column
names.

But if all you want is the column names, you could use this query for
MSSQLServer.

SELECT col.COLUMN_NAME as name
                FROM INFORMATION_SCHEMA.COLUMNS as col LEFT JOIN
INFORMATION_SCHEMA.TABLE_CONSTRAINTS as tabCon
                        ON col.TABLE_NAME = tabCon.TABLE_NAME
                        AND tabCon.CONSTRAINT_TYPE = 'PRIMARY KEY'
                LEFT JOIN INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE as colCon
                        ON col.COLUMN_NAME = colCon.COLUMN_NAME
                        AND col.TABLE_NAME = colCon.TABLE_NAME
                        AND colCon.CONSTRAINT_NAME = tabCon.CONSTRAINT_NAME
                WHERE col.TABLE_NAME = 'whatevertablename'

Cheers
Mike Kear
Windsor, NSW, Australia
Adobe Certified Advanced ColdFusion Developer
AFP Webworks
http://afpwebworks.com
ColdFusion, PHP, ASP, ASP.NET hosting from AUD$15/month



On 5/3/07, Steve Onnis <[EMAIL PROTECTED]> wrote:
>
> There is actually a built in stored proceedure for this stuff in MSSQL
>
> sp_tables gets all the tables in a database
>
> sp_columns gets all the columns in a table
>
> Look up in the sql help on how to use them
>
> Steve

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"cfaussie" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cfaussie?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to