How can I find a table in SQL server 2016

How can I find a table in SQL server 2016.
I could use this to find the table in the current database:
SELECT *
FROM sys.Tables
WHERE name LIKE '%Application_Current_Sequence_Number%'


The problem is, I have several databases on the server.

Kindly help.
Olugbnega OyeneyeDeveloperAsked:
Who is Participating?
 
Vitor MontalvãoMSSQL Senior EngineerCommented:
So you want to find a table but you don't know in each database is it?
If so then use sp_MSforeachdb and run the following:
USE Master
GO
EXEC sp_MSforeachdb
@command1='use ?; SELECT *
 FROM sys.Tables
 WHERE name LIKE ''%Application_Current_Sequence_Number%'''

Open in new window

0
 
Olugbnega OyeneyeDeveloperAuthor Commented:
I got this error message:

Msg 208, Level 16, State 1, Line 3
Invalid object name 'sys.Tables'.
0
 
Vitor MontalvãoMSSQL Senior EngineerCommented:
Are you running in a SQL Server 2016 instance, right?
Is that instance Case Sensitive? If so, then write sys.tables in lower case:
USE Master
GO
EXEC sp_MSforeachdb
@command1='use ?; SELECT *
 FROM sys.tables
 WHERE name LIKE ''%Application_Current_Sequence_Number%'''

Open in new window

0
 
Olugbnega OyeneyeDeveloperAuthor Commented:
It works.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.