dotnetspider.com
Login Login    Register      

TutorialsForumCareer DevelopmentResourcesReviewsJobsInterviewCommunitiesProjectsTraining

Subscribe to Subscribers
Talk to Webmaster
Tony John

Facebook
Google+
Twitter
LinkedIn
Online MembersAsheej T K
baskar
Shine S
More...
Join our online Google+ community for Bloggers, Content Writers and Webmasters




Resources » SQL Server

Debug your stored procedure


Posted Date:     Category: SQL Server    
Author: Member Level: Diamond    Points: 50


In this article i have explained how to debug your stored procedure with the digramatic representation. Many developer unaware of debugging in Stored Procedure with the help of visual studio SQL server addins, this article really helpful for them



 


Debug your stored procedure



History


We can debug our .NET application easily using a debugger from debug menu, .NET application has it's own .PDB (Program Debug Database) file that
used to store Debug location and can used to convert MSIL code.
This all about .NET but can we debug our stored procedures ?
The answer is Yes. Let's go through the document to check how to debug stored procedure

Introduction


Many times stored procedure play an important role in development life cycle. Stored procedure are not only responsible for query execution but also
responsible for playing an important logic.
Many project does not have a Business logic layer with them, This role can be play by using stored procedure.
Debug is process markingout code step by step. Here we can debug stored procedure using Visual studio editor without using SQL Management studio

Stepwise cooking


1. The first step is to create a Stored procedure that we need to debug (if you have stored procedure already created then you can skip this step)
here i am creating a simple stored procedure for fetching a value from table procedure name is sp_empInfo

Create_procedure


---------------------------------------

2. After creating stored procedure we need to open it through Microsoft Visual studio
Microsoft visual studio has already install SQL addins so we don't need to use SQL server management studio
- The first step we need to execute is open Visual studio editor
- Click on ViewMenu --> Server Explorer
- In Server explorer Pane right click on Data Connections
- Select Add connection

Add_connection


---------------------------------------

3. Now Add connection window will open we need to enter different parameters in Add Connection window, The parameters are
1. Server Name/IP address : Server name/IP Address where Database is installed
2. Authentication for SQL (Windows/sql authentication) here i use SQL authentication
3. Select or enter database name
4. click on Test connection to check if connection is properly established
5. Click on "OK" button to create connection with database

connection_param


---------------------------------------

4. After connection has been successfully established we need to a data connection will be visible in Server explorer
collapse treeview up to stored procedure and select your stored procedure, in my case i select sp_EMP_INFO

After_Connection


---------------------------------------

5. After selecting desired stored procedure we need to debug it, Right click the selected stored procedure, and click on Step Into Stored Procedure

check following snap

Step_into


---------------------------------------

6. After selecting Step Into Stored Procedure your stored procedure execution screen will open, in which, we can see different parameters list, Data types, Output parameters
value to be pass as input to stored procedure, enter some input to stored procedure and click on ok. In this case i have enter value as 10

check following snap

Run_stored_procedure


---------------------------------------

Yes we can use F10 directly to debug our stored procedure.

We can now go and check each and every parameters of stored procedure using this simple article

Suggestion and Queries always welcome

Thanks
Koolprasad2003





Did you like this resource? Share it with your friends and show your love!


Responses to "Debug your stored procedure"
Author: Pritom Nandy    28 Nov 2012Member Level: Gold   Points : 0
It's a good one. Was not knowing that stored procedures can be debugged in this way. Thanks for sharing this.


Author: Sunil Jas    27 Dec 2012Member Level: Silver   Points : 3
I went till "Step Into Stored Procedure" step explained by you the window appeared same as the screen shots u posted for me as well. But when i pressed "Step Into Stored Procedure" then it showed an error.

It displayed as "unable to access the sql server debugging interface,the visual studio cannot connect to the remote computer a firewall maybe preventing remote communication via dcom to the remote computer"

After this an "exception" result as well displayed with an exception number.



Author: Prasad kulkarni    31 Dec 2012Member Level: Diamond   Points : 2
Hello sunil,
It looks that you attempt SQL debugging on a machine where SQL debugging is not enabled.
To enable Debugging on machine with SQL check following link.
http://msdn.microsoft.com/en-us/library/s0fk6z6e(VS.80).aspx

disable your windows firewall and then try to debug the application



Feedbacks      

Post Comment:




  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:   Sign In to fill automatically.
    Email: (Will not be published, but required to validate comment)



    Type the numbers and letters shown on the left.


    Next Resource: How to delete duplicate record from SQL Server table?
    Previous Resource: How to delete all stored procedures
    Return to Resources
    Post New Resource
    Category: SQL Server


    Post resources and earn money!
     
    More Resources
    Popular Tags   Tag posting guidelines   Search Tags  
    Debug your stored procedure  .  



    Follow us on Twitter: https://twitter.com/dotnetspider

    Active Members
    TodayLast 7 Daysmore...

    Awards & Gifts
    Email subscription
  • .NET Jobs
  • .NET Articles
  • .NET Forums
  • Articles Rss Feeds
    Forum Rss Feeds


    About Us    Contact Us    Copyright    Privacy Policy    Terms Of Use    Revenue Sharing sites   Advertise   Talk to Tony John
    Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India
    2005 - 2012 All Rights Reserved.
    .NET and other trademarks mentioned in this site belong to Microsoft and other respective trademark owners.
    Articles, tutorials and all other content offered here is for educational purpose only.
    We are not associated with Microsoft or its partners.