Monday, January 3, 2011

Finding the Columns in a Database with Specific Names

You can use this T-SQL Query on SQL Server 2005 or greater to find all the columns that contain a word. In this example it would look for any column with the word number in it.

USE DataBase
GO

SELECT table_name
      ,column_name 'Column Name'
      ,data_type 'Data Type'
      ,character_maximum_length 'Maximum Length'

FROM information_schema.columns
WHERE column_name LIKE '%number%'
GO 

0 comments:

Post a Comment