Have you ever needed to find multiple occurrences of a column in a database schema? Consider using SYSOBJECTS and SYSCOLUMNS to discover which tables they reside within: SELECT B.NAME AS TABLE_NAME, A.NAME AS COLUMN_NAME FROM SYSCOLUMNS A INNER JOIN SYSOBJECTS B ON A.ID = B.ID AND B.XTYPE = 'U' WHERE A.NAME LIKE ‘%zip%’ A.LENGTH = 5 For a brief example of where this might be used, please refer to my blog entry titled "Finding Similar Columns In A Haystack" at www.johnmagnabosco.com
SQL Server Tips Home SQL Server Articles Home SQL Server Scripts Home
FREE Subscription to SQL Server Technical Newsletter SQL Tips, SQL Scripts, SQL Articles, SQL Job Opportunities, SQL News, SQL Technical Interviews, etc.