Click here to Skip to main content
13,195,026 members (99,579 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as

Stats

33.8K views
4 bookmarked
Posted 9 May 2010

Getting all table and schema names containing particular column name

, 20 Oct 2011
Rate this:
Please Sign up or sign in to vote.
Getting all table and schema names containing particular column name
Sometimes, we have a database containing hundreds of tables and we need to find a table containing a particular column name.

In the following SQL, just replace %email% by desired own column name to get the table(s) name in which such column may exist!

SELECT t.name AS table_name,
SCHEMA_NAME(t.schema_id) AS schema_name,
c.name AS column_name,
type.name as column_datatype,
c.max_length AS column_Length
FROM sys.tables AS t
INNER JOIN sys.columns c ON t.OBJECT_ID = c.OBJECT_ID
JOIN sys.types type ON c.system_type_id=type.system_type_id
WHERE c.name LIKE '%email%' AND type.name <> 'sysname' 
ORDER BY schema_name, table_name;

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Mahmudul Haque Azad
Software Developer (Senior) Vizrt Bangladesh
Bangladesh Bangladesh
I am truly versatile and 360 degree Engineer having wide range of development experience in .NET and Java Platform. I am also proficient in system level programming in C++. To me technology is not at all a problem, it’s the client requirement that matters! That is I am ready and comfortable to use any technology to make the business of my client a success.

In my five years of experience I have the opportunities to work for fortune 500 companies of US and many renowned clients from Europe.

My Linkedin Profile: http://bd.linkedin.com/in/mahmudazad

You may also be interested in...

Pro

Comments and Discussions

 
GeneralReason for my vote of 5 My vote 5 Pin
adit_sheth20-Oct-11 0:34
memberadit_sheth20-Oct-11 0:34 
QuestionMS specific Pin
Member 308248724-Oct-11 23:26
memberMember 308248724-Oct-11 23:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.171018.2 | Last Updated 20 Oct 2011
Article Copyright 2010 by Mahmudul Haque Azad
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid