Reputation: 8626
If my database has large set of tables then -
Is there any way / query which will search - which table contains particular column name ?
Eg. I want to know the name of table which contains column par_token
.
How can I achieve this? - I am using SQL Management Studio 2014.
Upvotes: 0
Views: 72
Reputation: 1269445
I recommend using INFORMATION_SCHEMA.COLUMNS
. The INFORMATION_SCHEMA
views are (relatively) standard views available across databases. And, you don't need any joins:
select c.*
from information_schema.columns c
where c.column_name = 'par_token';
Upvotes: 1
Reputation: 95534
You can use the sys
objects:
SELECT s.[name] AS SchemaName,
t.[name] AS TableName
FROM sys.schemas s
JOIN sys.tables t ON s.schema_id = t.schema_id
JOIN sys.columns c ON t.object_id = c.object_id
WHERE c.[name] = N'par_token';
Upvotes: 2