Link to home
Start Free TrialLog in
Avatar of Olugbnega Oyeneye
Olugbnega OyeneyeFlag for United Kingdom of Great Britain and Northern Ireland

asked on

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.
ASKER CERTIFIED SOLUTION
Avatar of Vitor Montalvão
Vitor Montalvão
Flag of Switzerland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Olugbnega Oyeneye

ASKER

I got this error message:

Msg 208, Level 16, State 1, Line 3
Invalid object name 'sys.Tables'.
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

It works.