Find Out Which Database Contain A Table

Sometimes it is very important to query the database meta-data in order to be fast and efficient. SQL code to query the System Database metadata to find out which database has a table you are looking for is simply below:

SQL code

Select * from sys.databases
WHERE  CASE
  WHEN state_desc = 'ONLINE' 
  THEN OBJECT_ID(QUOTENAME(name) + '.[dbo].[PutTheNameOfTable]', 'U')
   END IS NOT NULL





Edit this Article
Was this page helpful?
Yes Yes! this solution to the problem was helpful. No No! this solution to the problem was not helpful.. Leave ErnesTech Feedback.Feedback
If you log in, you will be notified when someone leaves a comment.

Other users would like to know if this solution helped you.

Your Session is Ending
Login to Continue

© 2021 - ErnesTech - Privacy