March 27, 2008 at 3:38 am
Hi all,
i need a query to get what are the tables that have the value 'cat'.
March 27, 2008 at 1:25 pm
Are you trying to search for 'cat' in a particular column or every column of every table? What exactly is the purpose for this search?
March 27, 2008 at 7:16 pm
Can you please clarify that you need 'cat' as value in column or substring in column name?
March 28, 2008 at 12:15 am
Hai all,
Suppose i am having 10 tables in a database.in that 10 tables,5 tables are having the column value as 'cat'.i need 5 tables name alone.more over it must be a single query.please don't go for cursor & while loop.
March 28, 2008 at 4:08 am
Hi,
I quess you should use the UNION for this.
SELECT Column1, Column2 FROM Table1 WHERE Column1='cat' OR Column2='cat'
UNION ALL
SELECT Column1, Column2 FROM Table2 WHERE Column1='cat' OR Column2='cat'
UNION ALL
SELECT Column1, Column2 FROM Table3 WHERE Column1='cat' OR Column2='cat'
UNION ALL
......
March 28, 2008 at 6:16 am
vmsbalaji (3/28/2008)
Hai all,Suppose i am having 10 tables in a database.in that 10 tables,5 tables are having the column value as 'cat'.i need 5 tables name alone.more over it must be a single query.please don't go for cursor & while loop.
This will do it...
SELECT Table_Catalog AS DBName,
Table_Schema AS Owner,
Table_Name AS TableName
FROM Information_Schema.Columns
WHERE Column_Name = 'Cat'
--Jeff Moden
Change is inevitable... Change for the better is not.
March 28, 2008 at 1:36 pm
vmsbalaji (3/28/2008)
Hai all,Suppose i am having 10 tables in a database.in that 10 tables,5 tables are having the column value as 'cat'.i need 5 tables name alone.more over it must be a single query.please don't go for cursor & while loop.
Value of the data in the column, or column name cat? Can you give an example of how you would do it with 1 table? You are being very unclear. Is the column name the same in all cases?
Or are we talking about looking for the value of 'cat' in every row of every column of every table in every database?
Please try to re-word again.
Thank you
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply