SQL Server and Find all Columns in a Database

Where the column name matches exactly…
SELECT name FROM sysobjects WHERE id IN ( SELECT id FROM syscolumns WHERE name = '{text}' )

Where the column name is like…
SELECT name FROM sysobjects WHERE id IN ( SELECT id FROM syscolumns WHERE name like '%{text}%' )

The following will show all occurrences of the column in any object
SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE COLUMN_NAME LIKE '%doctorid%'

Author

Admin

comments powered by Disqus

Categories

Recent Tweets

@ACLU n to pay for a long time. I yu the
#Xamarin Certified Trophy arrived today! @XamarinU thanks! https://t.co/TpYsSkBW6Y
Retweeted by @dyardy #PowerShell and Kerberos double hop. Slides, module, and demos. aka.ms/pskdh #PshSummit
@danrigby @Raspberry_Pi Very cool, let us know how it goes, thx