Wednesday, 23 January 2013

Find the Name of all Tables alongwith the Column Names in a Database


Find the Name of all Tables alongwith the Column Names in a Database


As the name suggest, You can achieve the same using the following Query:


SELECT TOP 100 PERCENT WITH TIES c.TABLE_NAME , COUNT(*) NumColumns

FROM INFORMATION_SCHEMA.[COLUMNS ] c

inner join INFORMATION_SCHEMA.[TABLES] t

ON C.TABLE_SCHEMA = t.TABLE_SCHEMA

and c.TABLE_NAME = T.TABLE_NAME

GROUP BY c.TABLE_NAME

ORDER BY c.TABLE_NAME

No comments:

Post a comment

Thank You for Your Comments. We will get back to you soon.

back to top