Wednesday, August 27, 2008 Register   Login   
   You Are Here: Tips & Tricks » SQL Tip of the Day     
 SQL Community Portal
  
 Recently Submitted Articles
  
 Recent SQL Clinic Articles
  
  
Redgate SQL Server Tools
  
 SQL Server Community Resources (Tips, Articles & Scripts) by SQL Server Gurus

     

< BACK  1 of 104  NEXT >

Permalink
Finding An Occurrence of a Column

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


Posted @ 6/15/2008 10:35:10 PM by | COMMENTS (0)


< BACK  1 of 104  NEXT >

     SQL Server Tips Home          SQL Server Articles Home         SQL Server Scripts Home


Syndicate    
SQL Server 2000 Downloads
 
SQL Server 2000 Reporting Services Downloads
 
SQL Server 2000 Notification Services SP Downloads
 
SQL Server CE Downloads
 
SQLXML 3.0 Service Pack Downloads
 
SQL Server 2000 JDBC Driver
 
MDAC 2.6 Download
 
SQL Server 2000 Tools Downloads
SQL Server 2005 & SQL Server 2000 Best Practices
·    DMV Stats
 
·    Buffer Cache
·    Input/Output
·    Performance
·    Tempdb
·    Wait Statistics
                    
SQL Server 2000 Best Practices




Cancel  Send

 Community Sharing Central
  
 Recently Submitted SQL Tips
  
 Recently Submitted Scripts
  
Subscribe to newsletter
 Subscribe to SQL Server Technical Newsletters

FREE Subscription to SQL Server Technical Newsletter SQL Tips, SQL Scripts, SQL Articles, SQL Job Opportunities, SQL News, SQL Technical Interviews, etc.

Your Email Address
Select Your Country
.

  

SQL Home  |  Events  |  Discussions  |