Proxy > Gmail Facebook Yahoo!

Get columns and tables contain word



--get columns and tables contain word

select name as columnName,object_name(object_id)as tableName from sys.columns where object_id in
(select object_id from sys.tables where name like '%tableName%') and name like '%ColumnName%' order by tablename

OR

Select  Column_Name +' '+data_type + isnull('('+CAST(Character_Maximum_length
AS varchar(5))+')' ,'')+ ' ,' from information_schema.columns
where table_name ='Table Name'


Responses

1 Respones to "Get columns and tables contain word"

suneeltcs said... [Reply]

Benifits of this query...

Suppose you have 100 tables in your database.
and more than 100 column in each table.
you know the one column name but you dont know table name in which your column exist...
you can find column name corresponding table name list......


24 April 2011 at 12:32

Send mail to your Friends.  

Expert Feed

 
Return to top of page Copyright © 2011 | My Code Logic Designed by Suneel Kumar