Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 611501
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T17:47:27+00:00 2026-05-13T17:47:27+00:00

I have a Stored Procedure, Which has some select Statements and insert statements. Is

  • 0

I have a Stored Procedure, Which has some select Statements and insert statements.

Is there any way , I can log the Timestamps of execution before and after the sqls inside the Stored procedure?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T17:47:27+00:00Added an answer on May 13, 2026 at 5:47 pm

    If this is not something you want to leave in permanently (i.e. it’s just for debugging/performance analysis purposes) then your best bet is to use SQL Profiler and monitor the SP:StmtCompleted event which will record the stats for each statement within a sproc. You can dump this data to a db table.

    Edit: Running SQL Profiler:
    1) In SSMS, under Tools, select SQL Server Profiler
    2) Connect to your db server you want to monitor
    3) In the trace properties dialog that appears, go to the Events Selection tab and tick the “Show all events” checkbox
    4) The grid will then show all types of events you can monitor. Find the Stored Procedures section, and in there cick the SP:StmtCompleted checkbox to define that you want to monitor that type of event.
    5) The general tab allows you to save the trace to a file, or to a db table if you want to. Or, you don’t have to save it to either, just display it to screen. You can always save it to a table/file later if you really need to.
    6) When you’re ready just click “Run”
    For a lot more info on SQL Profiler, see MSDN

    If this is something you want to keep (i.e. an audit table), then you’ll need to INSERT records into your own audit table yourself e.g.

    DECLARE @StartTime DATETIME
    SET @StartTime = GETDATE()
    
    SELECT Something FROM SomeTable WHERE....
    
    INSERT MyAuditTable (Statement, StartTime, EndTime)
    VALUES ('SELECT Something FROM SomeTable WHERE...', @StartTime, GETDATE())
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a stored procedure which basically does something like select top 1 expiryDate,
I have a stored procedure which is called inside a trigger on Insert/Update/Delete. The
I have a messy stored procedure which uses dynamic sql. I can debug it
We have a stored procedure in which there are two parts. In part 1,
I have a stored procedure which returns XML to the caller using a SELECT
I have a stored procedure which takes an XML parameter and inserts the data
I have a stored procedure which returns a ref cursor as follows: CREATE OR
I have a stored procedure which is doing a lot of delete. Hundreds of
I have a stored procedure which executes another procedure inside it. The second one
I have a stored procedure in which i want to create a user defined

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.