Solved

How can I find a table in SQL server 2016

Posted on 2016-10-18
4
61 Views
Last Modified: 2016-10-18
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.
0
Comment
Question by:Olugbnega Oyeneye
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 50

Accepted Solution

by:
Vitor Montalvão earned 500 total points
ID: 41848019
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
 

Author Comment

by:Olugbnega Oyeneye
ID: 41848022
I got this error message:

Msg 208, Level 16, State 1, Line 3
Invalid object name 'sys.Tables'.
0
 
LVL 50

Expert Comment

by:Vitor Montalvão
ID: 41848053
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
 

Author Closing Comment

by:Olugbnega Oyeneye
ID: 41848058
It works.
0

Featured Post

Get Database Help Now w/ Support & Database Audit

Keeping your database environment tuned, optimized and high-performance is key to achieving business goals. If your database goes down, so does your business. Percona experts have a long history of helping enterprises ensure their databases are running smoothly.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When table data gets too large to manage or queries take too long to execute the solution is often to buy bigger hardware or assign more CPUs and memory resources to the machine to solve the problem. However, the best, cheapest and most effective so…
When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Viewers will learn how the fundamental information of how to create a table.

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question