July 25, 2012 at 8:35 am
how to find table or SP in whole sql server 2008R
July 25, 2012 at 8:41 am
To find the table/SP use sys.all_objects and to find if the table exists in any db use sp_foreachdb. I leaving this as a home work for you to come out with logic using these two 🙂
~ Lokesh Vij
Link to my Blog Post --> www.SQLPathy.com[/url]
Follow me @Twitter
July 25, 2012 at 8:50 am
Can I get the query lokeshvij?
July 25, 2012 at 8:59 am
July 25, 2012 at 9:08 am
I thought you will do that...here's is the query:
sp_msforeachdb 'select "?" AS db, name from [?].sys.tables where name = ''table_name'''
Replace your table name with table_name
~ Lokesh Vij
Link to my Blog Post --> www.SQLPathy.com[/url]
Follow me @Twitter
July 25, 2012 at 9:21 am
lokeshvij (7/25/2012)
I thought you will do that...here's is the query:
sp_msforeachdb 'select "?" AS db, name from [?].sys.tables where name = ''table_name'''
Replace your table name with table_name
That won't work for SPs. Use sys.objects instead.
July 25, 2012 at 9:32 am
Yup...I forgot that its table/SP
Thanks for correcting me 🙂
~ Lokesh Vij
Link to my Blog Post --> www.SQLPathy.com[/url]
Follow me @Twitter
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply