Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
rammohan
Posting Yak Master
212 Posts |
Posted - 2008-10-10 : 03:28:18
|
| Dear All, I have n number of tables in my database x. here i want to list all the tables names which have column name 'y' in their design. how can i write query?One can never consent to creep,when one feels an impulse to soarRAMMOHAN |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-10-10 : 03:49:53
|
| SELECT TABLE_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE COLUMN_NAME='y' |
 |
|
|
rammohan
Posting Yak Master
212 Posts |
Posted - 2008-10-10 : 05:30:45
|
| Thanq very much visakh it's helped, but along with tables it is giving views also, how can i restrict it to only tablenames?One can never consent to creep,when one feels an impulse to soarRAMMOHAN |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-10-10 : 06:14:31
|
[code]SELECT c.TABLE_NAMEFROM INFORMATION_SCHEMA.COLUMNS AS cINNER JOIN INFORMATION_SCHEMA.TABLES AS t ON t.TABLE_CATALOG = c.TABLE_CATALOG AND t.TABLE_SCHEMA = c.TABLE_SCHEMA AND t.TABLE_NAME = c.TABLE_NAME AND t.TABLE_TYPE = 'BASE TABLE'WHERE c.COLUMN_NAME = 'y'[/code] E 12°55'05.63"N 56°04'39.26" |
 |
|
|
rammohan
Posting Yak Master
212 Posts |
Posted - 2008-10-10 : 07:59:55
|
| Thank you very much Peso.its helped meOne can never consent to creep,when one feels an impulse to soarRAMMOHAN |
 |
|
|
|
|
|