SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Old Forums
 CLOSED - General SQL Server
 how to access information of a table in other db
 Forum Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

sathyav
Starting Member

India
27 Posts

Posted - 08/24/2006 :  07:33:12  Show Profile
SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'tab_db1'


The above query will give the information of the table 'tab_db1' if it is available in the current database (say db1) connected.

How can i access the information of a table (say 'tab_db2') which is created under a different database say db2 from the current db connected say db1.

I tried the above query with changing the table_name to 'db2..tab_db2'
but went invain.

sysobjects also dint work..

Any help on this will be appreciated..

regards,
Sathya V

Today will be Yesterday Tomorrow - Do it now

Edited by - sathyav on 08/24/2006 07:38:52

chiragkhabaria
Flowing Fount of Yak Knowledge

India
1907 Posts

Posted - 08/24/2006 :  07:38:52  Show Profile  Visit chiragkhabaria's Homepage  Send chiragkhabaria a Yahoo! Message
Select * From db2..[Sysobjects] where type = 'U'

Chirag
Go to Top of Page

sathyav
Starting Member

India
27 Posts

Posted - 08/24/2006 :  07:44:06  Show Profile
Thanks for the reply chirag,

will it not be possible to use information_schema.tables for the purpose...

regards,
Sathya V

Today will be Yesterday Tomorrow - Do it now
Go to Top of Page

harsh_athalye
Flowing Fount of Yak Knowledge

India
5520 Posts

Posted - 08/24/2006 :  08:27:49  Show Profile  Visit harsh_athalye's Homepage  Click to see harsh_athalye's MSN Messenger address  Send harsh_athalye a Yahoo! Message
It is possible as shown below..

SELECT * FROM DB.INFORMATION_SCHEMA.TABLES


Harsh Athalye
India.
"Nothing is Impossible"
Go to Top of Page

sathyav
Starting Member

India
27 Posts

Posted - 08/24/2006 :  12:13:38  Show Profile
Thanks for answering my query Harsh, it works

Today will be Yesterday Tomorrow - Do it now
Go to Top of Page
  Previous Topic Topic Next Topic  
 Forum Locked
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000