Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How can I find a table in SQL server 2016

Posted on 2016-10-18
4
Medium Priority
?
65 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 52

Accepted Solution

by:
Vitor Montalvão earned 2000 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 52

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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
In this blog post, we’ll look at how using thread_statistics can cause high memory usage.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Via a live example, show how to shrink a transaction log file down to a reasonable size.

721 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