Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
in SQL by (20.3k points)

Is it possible to query for table names which contain columns being

LIKE '%myName%'


1 Answer

0 votes
by (40.4k points)

Head over to this video to understand LIKE Operator in SQL.

Use this Query to search Tables & Views:

SELECT      COL_NAME AS 'Column_Name', TAB_NAME AS 'Table_Name'


WHERE       COL_NAME LIKE '%MyName%'

ORDER BY    Table_Name, Column_Name;

• Schema.COLUMNS - the name of the schema of fetched column

• Table_Name - the name of the fetched table

• Here, one row represents a table


Use this Query to search the Tables:

SELECT  AS 'ColumnName', AS 'TableName'

FROM sys.columns col

JOIN sys.tables  tab  ON col.object_id = tab.object_id


ORDER BY TableName,ColumnName;

If you wish to learn SQL then visit this SQL Training.

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
asked Jan 5, 2021 in SQL by Appu (6.1k points)

Browse Categories