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

  • Home
  • SEARCH
  • 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 77357
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T20:49:03+00:00 2026-05-10T20:49:03+00:00

I’ve got the a SQL Server stored procedure with the following T-SQL code contained

  • 0

I’ve got the a SQL Server stored procedure with the following T-SQL code contained within:

insert into #results ([ID], [Action], [Success], [StartTime], [EndTime], [Process]) select     'ID' = aa.[ActionID],     'Action' = cast(aa.[Action] as int),     'Success' = aa.[Success],     'StartTime' = aa.[StartTime],     'EndTime' = aa.[EndTime],     'Process' = cast(aa.[Process] as int) from     [ApplicationActions] aa with(nolock) where     0 = case             when (@loggingLevel = 0) then 0             when (@loggingLevel = 1 and aa.[LoggingLevel] = 1) then 0         end     and     1 = case             when (@applicationID is null) then 1             when (@applicationID is not null and aa.[ApplicationID] = @applicationID) then 1         end     and     2 = case             when (@startDate is null) then 2             when (@startDate is not null and aa.[StartTime] >= @startDate) then 2         end     and     3 = case             when (@endDate is null) then 3             when (@endDate is not null and aa.[StartTime] <= @endDate) then 3         end     and     4 = case             when (@success is null) then 4             when (@success is not null and aa.[Success] = @success) then 4         end     and     5 = case             when (@process is null) then 5             when (@process is not null and aa.[Process] = @process) then 5         end 

It’s that ‘dynamic’ WHERE clause that is bothering me. The user doesn’t have to pass in every parameter to this stored procedure. Just the ones that they are interested in using as a filter for the output.

How would I go about using SQL Server Studio or Profiler to test whether or not this store procedure is recompiling every time?

  • 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. 2026-05-10T20:49:04+00:00Added an answer on May 10, 2026 at 8:49 pm

    The following article explains how to find out if your stored procedure is recompiling: http://it.toolbox.com/blogs/programming-life/sql-performance-abnormal-stored-procedure-recompiles-8105

    Here’s a quote from the appropriate section:

    start SQL Profiler and start a new trace, connect to our server and give an appropriate trace name, select the events tab and remove the already existing events on the ‘Selected event classes’ list box. Now choose the ‘Stored Procedures’ node in the ‘Available event classes’ and add SPComplete, SPRecompile, SPStarting, SP:StmtStarting and SP:StmtCompleted. Now choose the ‘data columns’ tab and select just about the right amount of events and data columns that you need. Add filters to reduce the number of events you collect.

    I would filter by the name of your stored procedure.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Related Questions

Loading...

Sidebar

Ask A Question

Stats

  • Questions 54k
  • Answers 54k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer The 'Running Programs' applets simply enumerates the Form Text of… May 11, 2026 at 7:25 am
  • added an answer I found this tutorial very useful. Yes it is partially… May 11, 2026 at 7:25 am
  • added an answer You can discover the IP addresses the Google and others… May 11, 2026 at 7:25 am

Top Members

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

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.