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
Newsletter
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Requirements, Code, and Tests: How Venn Diagrams Can Explain It All
  • Maven Dependency Scope Applied
  • Java: A Time-Tested Programming Language Still Going Strong
  • Writing an Interpreter: Implementation

Trending

  • Reading GC Logs: Memory Leak or Undersized Heap?
  • 5 Mistakes Companies Make When Working With Staff Engineers
  • Managing Technical Debt in AI-Generated Code
  • Building Enterprise Authentication With Angular, Spring Boot, SSO, and MFA

Draft This article hasn't been published, so readers can't see it.

In moderation This article is waiting for review, so readers can't see it yet.

Deleted This article has been deleted, so readers can't see it.

  1. DZone
  2. Data Engineering
  3. Data
  4. Finding Dependency in Stored Procedure

Finding Dependency in Stored Procedure

By 
Joydeep Das
·
Jul. 03, 15 · Interview
Post on X (opens in a new tab) Share on LinkedIn (opens in a new tab)
12.3K Views

Join the DZone community Save articles, join the discussion, and download Refcards and Trend Reports with a free account.

Join for free Already a member? Log in

Introduction

Here in this article we are trying to discuss about the finding reference object within stored procedure and also finding the calling procedure references. Hope you like it and it will be informative.

What We Want

Developers are writing several stored procedure almost every day. Sometimes developers need to know about the information such as what object is used within the stored procedure or from where (SP) the specified stored procedure call. This is the vital information for the developer before working on a particular stored procedure.
Here we are representing a pictorial diagram to understand the nature of implementation.
Now we have to answer some question
1.  What are the DB Object used in Stored Procedure1 and there type.
2.  In case of Store Procedure3 which procedure calls the Store Procedure3
So we are not going to read the Stored Procedure to find the answer. Suppose the each procedure have more than 3000 line.

How We Solve the Answer

To solve the answer first we take the example and create an example scenario to understand it.

 -- Base Table
CREATE TABLE T1
          (EMPID  INT, EMPNAME  VARCHAR(50));
GO

 CREATE TABLE T2
          (EMPID  INT, EMPNAME  VARCHAR(50));
GO
--1
CREATE PROCEDURE [dbo].[Procedure1]
AS
BEGIN
    SELECT * FROM T1;
      SELECT * FROM T2;
      EXEC [dbo].[Procedure3];
END
GO

--2
CREATE PROCEDURE [dbo].[Procedure2]
AS
BEGIN
    EXEC [dbo].[Procedure3];
END
GO

--3
CREATE PROCEDURE [dbo].[Procedure3]
AS
BEGIN
    SELECT * FROM T1;
END
GO

Now we are going to solve the question

What are the DB Object used in Stored Procedure1 and there type.

sp_depends Procedure1

In case of Store Procedure3 which procedure calls the Store Procedure3


 SELECT OBJECT_NAME(id) AS [Calling SP]
FROM   syscomments
WHERE  [text] LIKE '%Procedure3%'
GROUP BY OBJECT_NAME(id);

Hope you like it.

Dependency Object (computer science) dev VITAL (machine learning software) Implementation Diagram

Opinions expressed by DZone contributors are their own.

Related

  • Requirements, Code, and Tests: How Venn Diagrams Can Explain It All
  • Maven Dependency Scope Applied
  • Java: A Time-Tested Programming Language Still Going Strong
  • Writing an Interpreter: Implementation

Partner Resources

×

Comments

Loading comments

The comments didn't load

Please try again in a moment.

Likes

Loading

The next likes didn't load. Please try again.

The likes didn't load

Please try again in a moment.

See who liked this

Log in or join DZone for free to see who liked this article.

Log in Join for free
  • 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