Epic Puck

A follow up to - Did I use that column before?

by on Sep.09, 2011, under Coding, SQL

This query will get you all of the tables, columns and column details for a database. You will need to substitute the column name with the name of the column that you are looking for.

SELECT table_name=sysobjects.name,
         column_name=syscolumns.name,
         datatype=systypes.name,
         length=syscolumns.length
    FROM sysobjects
    JOIN syscolumns ON sysobjects.id = syscolumns.id
    JOIN systypes ON syscolumns.xtype=systypes.xtype
   WHERE sysobjects.xtype='U'
   AND syscolumns.name like '%column name%'
ORDER BY sysobjects.name,syscolumns.colid
Be Sociable, Share!
:list all columns, list all tables, sql, syscolumns, sysobjects, systypes

Comments are closed.

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!