DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Monitoring and Managing the Growth of the MSDB System Database in SQL Server
  • Using AUTHID Parameter in Oracle PL/SQL
  • How To Generate Scripts of Database Objects in SQL Server
  • Different Ways To Rename Database Objects

Trending

  • Docker Hardened Images Are Free Now — Here's What You Still Need to Build
  • Why DDoS Protection Is an Architectural Decision for Developers
  • Edge Computing in Utility IoT: Two Architecture Patterns That Actually Work
  • How to Format Articles for DZone
  1. DZone
  2. Data Engineering
  3. Databases
  4. Find Invalid Objects in SQL Server Databases

Find Invalid Objects in SQL Server Databases

In this article, we are going to take a closer look at the issue of how to find invalid objects in SQL Server databases.

By 
Evgeniy Gribkov user avatar
Evgeniy Gribkov
·
Jul. 14, 20 · Tutorial
Likes (3)
Comment
Save
Tweet
Share
6.8K Views

Join the DZone community and get the full member experience.

Join For Free

In the course of time, we can experience situations when some certain database objects have not been distributed on one or several databases or database instances. This can happen for a number of reasons. An example of that would be a case when a stored procedure refers to a nonexistent table. In this article, we are going to take a closer look at the issue of how to find invalid objects in SQL Server databases with the help of dbForge SQL Complete.

To have a much more complete insight into the functionality of this tool, you will first need to consider the previous series of our articles. This piece is going to be the final thought closing the series of Deleting Lost Transactions in MS SQL Server articles. So let’s go over the topics we have discussed and review what we have accomplished previously:

  • Analyzing the algorithm of deleting lost transactions.
  • Creating a stored procedure using CRUD.
  • Testing the stored procedure and turning it into a script. 
  • Reviewing a number of useful settings that vastly help in the workflow.

Finding Invalid Objects

Apart from its other functions, with the help of the SQL Complete tool, we can find invalid objects in SQL Server. To do that, first, select the SQL Complete\Find Invalid objects command in the main menu:

Choosing the “Find Invalid Objects” command in the SQL Complete main menu

Once it’s done, in the window that opens, we select the required databases from MS SQL Server instances and press “Analyze” at the upper right corner or at the middle of the screen:

Setting up and running the search for references to invalid objects

Now, the process of searching for references to invalid objects starts: 

The search process

After the process is completed, you will see a table containing all objects that refer to invalid objects:

The table showing all objects that refer to invalid database objects

As you can see here, the table displays the type, schema, and name of the object that refers to the invalid object, the name of which is also displayed. At the bottom, you can see the code of the object that refers to the invalid object. In this case, the DeleteArchive stored procedure refers to the nonexistent srv.KillSession table, which is an unresolved reference to the object.

After that, you can proceed to the location of the stored procedure, by right-clicking on it and selecting “Find in Object Explorer” in the context menu:

Finding the object that refers to an invalid database object

Finally, it will be enough to analyze the code of the stored procedure, which refers to the nonexistent table, and decide whether you need to create the srv.KillSession table:

The code analysis result

Summary

In this final part of articles, we walked through the whole process of finding invalid database objects, providing a step-by-step guide of how to accomplish that using the dbForge SQL Complete tool. The result leaves the user with a decision whether to create the nonexistent object or change the reference to the existing one.

Database Object (computer science) sql

Published at DZone with permission of Evgeniy Gribkov. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Monitoring and Managing the Growth of the MSDB System Database in SQL Server
  • Using AUTHID Parameter in Oracle PL/SQL
  • How To Generate Scripts of Database Objects in SQL Server
  • Different Ways To Rename Database Objects

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook