Saturday, 19 July 2014

SQL Find a Column in all Tables


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'
WHERE syscolumns.name='UID'
ORDER BY sysobjects.name,syscolumns.colid