How can I figure out a table (say tbl_mytable) lies in which database?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you’re using SQL Server 2005 or above and this is an adhoc thing, rather than a programmatic thing, you can try SQL Search by Red Gate. It’s a free Management Studio plugin.
Edit:
Programmatically, you can do it via sp_MSForEachDB which is an undocumented system procedure – so, functionality is not guaranteed to behave the same or even exist between releases (i.e. don’t use in production code).
This will print a list of database names which contain the table.