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

  • 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

  • How to Format Articles for DZone
  • From printTriangularNumber to Duff’s Device: Mastering Java Switch Statements Old and New
  • The AI Autonomy Spectrum: 7 Architecture Patterns for Intelligent Applications
  • WebSocket Debugging Without a Proxy — A Browser-First Workflow
  1. DZone
  2. Data Engineering
  3. Data
  4. Finding Dependency in Stored Procedure

Finding Dependency in Stored Procedure

By 
Joydeep Das user avatar
Joydeep Das
·
Jul. 03, 15 · Interview
Likes (0)
Comment
Save
Tweet
Share
12.2K Views

Join the DZone community and get the full member experience.

Join For Free

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

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