From: Pingx on
Dear SQL Server Export,
How do I find a certain table in sql server assuming I do not know the name
of the database. sysobjects does not work. and INFORMATION_SCHEMA.TABLES does
not work either. You have to know the db name in both cases.


From: Tom Cooper on
sp_msforeachdb 'Use [?]; If Exists(Select * From sys.tables Where name =
''MyTable'') Select ''table was found in the ? database''';

will show you every database where there is a table named MyTable. Please
note that sp_msforeachdb is an undocumented stored procedure and Microsoft
could change or remove it in future releases.

Tom

"Pingx" <Pingx(a)discussions.microsoft.com> wrote in message
news:0FC72149-89F1-4922-8B5B-534DBCF24919(a)microsoft.com...
> Dear SQL Server Export,
> How do I find a certain table in sql server assuming I do not know the
> name
> of the database. sysobjects does not work. and INFORMATION_SCHEMA.TABLES
> does
> not work either. You have to know the db name in both cases.
>
>

From: Uri Dimant on
Hi
SELECT * FROM sys.tables

"Pingx" <Pingx(a)discussions.microsoft.com> wrote in message
news:0FC72149-89F1-4922-8B5B-534DBCF24919(a)microsoft.com...
> Dear SQL Server Export,
> How do I find a certain table in sql server assuming I do not know the
> name
> of the database. sysobjects does not work. and INFORMATION_SCHEMA.TABLES
> does
> not work either. You have to know the db name in both cases.
>
>


From: Pingx on
sys.tables has the same data as the other two cases. you have to know the db
name first.

Pingx

"Uri Dimant" wrote:

> Hi
> SELECT * FROM sys.tables
>
> "Pingx" <Pingx(a)discussions.microsoft.com> wrote in message
> news:0FC72149-89F1-4922-8B5B-534DBCF24919(a)microsoft.com...
> > Dear SQL Server Export,
> > How do I find a certain table in sql server assuming I do not know the
> > name
> > of the database. sysobjects does not work. and INFORMATION_SCHEMA.TABLES
> > does
> > not work either. You have to know the db name in both cases.
> >
> >
>
>
> .
>
From: Pingx on
Thanks Tom.
I'm surpprised that sql server does not have a table/view to list all the
tables instance wide.

Pingx

"Tom Cooper" wrote:

> sp_msforeachdb 'Use [?]; If Exists(Select * From sys.tables Where name =
> ''MyTable'') Select ''table was found in the ? database''';
>
> will show you every database where there is a table named MyTable. Please
> note that sp_msforeachdb is an undocumented stored procedure and Microsoft
> could change or remove it in future releases.
>
> Tom
>
> "Pingx" <Pingx(a)discussions.microsoft.com> wrote in message
> news:0FC72149-89F1-4922-8B5B-534DBCF24919(a)microsoft.com...
> > Dear SQL Server Export,
> > How do I find a certain table in sql server assuming I do not know the
> > name
> > of the database. sysobjects does not work. and INFORMATION_SCHEMA.TABLES
> > does
> > not work either. You have to know the db name in both cases.
> >
> >
>
> .
>