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 3482140
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T10:31:29+00:00 2026-05-18T10:31:29+00:00

Me and my colleagues have a question regarding SQL Server 2008 query length and

  • 0

Me and my colleagues have a question regarding SQL Server 2008 query length and the SQL Server Optimizer.

We are planning to generate some stored procedures that potentially have a lot of parameters. Inside of our stored procedure we will simply select some values from a table joining other tables.

Our stored procedures will look like this

CREATE PROCEDURE QueryTable
@Parameter001 nvarchar(20),
@Parameter002 int,
@Parameter003 datetime,
@Parameter004 decimal(11,2),
@Parameter005 date,
@Parameter006 varchar(150),
@Parameter007 int,
@Parameter008 decimal(5,2),
@Parameter009 nvarchar(10),
@Parameter010 nvarchar(200),
@Parameter011 nvarchar(50) --,
--...and so on, there are probably 50 to 100 parameters here

AS
BEGIN
SET NOCOUNT ON;

SELECT ID, COL01, COL02, COL03, COL04, COL05 from TestTable T
LEFT JOIN AnotherTable A On T.SomeColomn = A.SomeColumn
LEFT JOIN AThirdTable ATT On A.ThirdTableID = ATT.Id
--and so on, probably 5-10 Tables joined here
WHERE 
      T.Col02 = @Parameter001 AND
      T.Col05 = @Parameter004 AND
      ATT.SomeColumnContainingData = @Parameter027
      A.AnotherID = @Parameter050
      --probably 50 to 100 conditions here (Number of conditions equals number of parameters)
END
GO

Our questions:
Is there a limit on the amount of where-conditions that the Query Optimizer and the SQL Server Cache can take into account?
If there is not such a technical limit, is there a best practice on how many conditions can and should be used in such cases?

  • 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-18T10:31:29+00:00Added an answer on May 18, 2026 at 10:31 am

    In case anyone is interested…

    We solved this issue by generating dynamic sql that is executed on the server. In this way only relevant where clauses are used and the statement is relatively short.

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

Sidebar

Related Questions

Our database server is a SQL 2008 server. My colleagues all have XP service
Recent conversations with colleagues have produced varying points of view on this matter. What
Today my colleagues and me have a discussion about the usage of the final
Yesterday, I have a discussion with my colleagues about HTTP. It is asked why
Myself and a colleague have a dispute about which of the following is more
I have a colleague who is looking into opcode caching/Zend Acceleration (I've always assumed
I have a colleague who insists that his code doesn't need comments, it's "self
A colleague and I have spent a few years developing a really cool Matlab
I have read (or perhaps heard from a colleague) that in .NET, TransactionScope can
A colleague of mine and I have been discussing how to declare variables in

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.