March 10, 2010 at 4:45 am
Hai Experts,
How to Find a Table on Different databases in SQL Server?
Plz help me!
March 10, 2010 at 9:16 am
I don't understand your question. Would you elaborate please?
Thanks
Greg
March 10, 2010 at 7:06 pm
Try this query.
select * from sys.sysobjects
where = 'table_name'
You can make a loop for search in all databases.
I hope help you.
Fabrício França Lima
MCITP – Database Administrator
https://www.fabriciolima.net/Blog
March 11, 2010 at 12:49 am
Hi Subha,
You can run the below select query as a sample.
This will check all databases on the related instance for a specific table name
EXEC sp_Msforeachdb "use [?];select '[?]' dbname,* from sys.tables where name = 'customers'"
You can find more samples here on sp_Msforeachdb Example : List All Database Files using sp_Msforeachdb Undocumented Stored Procedure
I hope that is what you are looking for!
Eralper
March 11, 2010 at 1:04 am
The solution by Eralper should work just fine.
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
March 11, 2010 at 7:12 am
thank you sir
its working fine
March 11, 2010 at 7:14 am
sir,
its not working..........
once verify it..
March 11, 2010 at 7:17 am
Hi subha,
What is the error message, etc you get when you execute the query?
And what is the SQL version, perhaps you should use sysobjects instead of sys.tables
Eralper
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply