Description:-
In this example we explain that how to find all tables
containing column with specified name in SQL Server. Or Query to find column
from all tables of database.
How many tables
in your database have column name like ‘LeadId’?
This was an interesting question if someone ask you or
if you have requirement like above question then what to do?
Once way is to you manually check the table one by one
and check that this column is exists in table or not but if there are 1000
tables in your database then it was very time consuming. So best way is to
write the following query and get your result in just one second.
SELECT
c.name AS
ColName, t.name
AS TableName
FROM sys.columns c
JOIN sys.tables t ON c.object_id = t.object_id
WHERE c.name LIKE '%LeadId%'
0 comments:
Post a Comment