I m using SQL Server 2005 and trying to get table name "myTable" from all databases from SQL Server
begin try
Exec sp_MSforeachdb 'Select * From ?..sysobjects where name=''myTable'''
end try
begin catch
print 'error'
end catch
begin try
Exec sp_MSforeachdb 'Select * From ?..sysobjects where name=''myTable'''
end try
begin catch
print 'error'
end catch
Modifying the Exec sp_MSforeachdb statement to
ReplyDeleteExec sp_MSforeachdb 'Select ''[?]'',* From ?..sysobjects where name=''ProductPlacementSet'''
will display the Database name along with the additional sysobjects data.