I want to get a list of tables exist in another database. for example if i have connected DB1 database and i want to get a list of tables from DB2 then how is it possible?
I know there are some another approaches like connect DB2 and execute insert query to insert schema into #temp table then connect DB1 using USE [DB1]
statement and use that #temp table.
But, I don't want to change my sql connection at runtime. Because, there are some dependencies i have created on my sql connection.
UPDATED:
Database can be restored in same server. Now i am using following query to get Table List from the database.
SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE='BASE TABLE'
version of sql server is 2005.