Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 check for index existance from another db

Author  Topic 

subhaoviya
Posting Yak Master

135 Posts

Posted - 2012-10-03 : 10:19:11
Hi,

I am forming queries in DB1 and for one of my query i need to acces the table of DB2. to make the performance faster i just need to create an index on searching column of that target table of DB2.

while i am trying to check for indexes on that particular table i am getting error like
The multi-part identifier "DB1.dbo.Table" could not be bound.

the query that i tried

USE DB1
select * from SYS.indexes where object_id=object_id(DB1.dbo.table)

thanks
subha

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-10-03 : 10:20:56
are the DBs in the same server?. you could try

USE [DB1]
GO
select * from SYS.indexes where object_name(object_id)='table'


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

subhaoviya
Posting Yak Master

135 Posts

Posted - 2012-10-03 : 10:22:29
yes both dbs are in same server
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-10-03 : 10:28:37
try last posted query as well

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -