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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:02:06+00:00 2026-05-22T18:02:06+00:00

A specification essentially is a text string representing a where clause created by an

  • 0

A specification essentially is a text string representing a “where” clause created by an end user.

I have stored procedures that copy a set of related tables and records to other places. The operation is always the same, but dependent on some crazy user requirements like “products that are frozen and blue and on sale on Tuesday”.

What if we fed the user specification (or string parameter) to a scalar function that returned true/false which executed the specification as dynamic SQL or just exec (@variable).
It could tell us whether those records exist. We could add the result of the function to our copy products where clause.

It would keep us from recompiling the copy script each time our where clauses changed. Plus it would isolate the product selection in to a single function.

Anyone ever do anything like this or have examples? What bad things could come of it?

EDIT:

This is the specification I simply added to the end of each insert/select statement:

and exists (
    select null as nothing
    from SameTableAsOutsideTable inside
    where inside.ID = outside.id and      -- Join operations to outside table

          inside.page in (6, 7) and       -- Criteria 1
          inside.dept in (7, 6, 2, 4)     -- Criteria 2
)

It would be great to feed a parameter into a function that produces records based on the user criteria, so all that above could be something like:

and dbo.UserCriteria( @page="6,7", @dept="7,6,2,4")
  • 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-22T18:02:07+00:00Added an answer on May 22, 2026 at 6:02 pm

    Dynamic Search Conditions in T-SQL

    When optimizing SQL the important thing is optimizing the access path to data (ie. index usage). This trumps code reuse, maintainability, nice formatting and just about every other development perk you can think of. This is because a bad access path will cause the query to perform hundreds of times slower than it should. The article linked sums up very well all the options you have, and your envisioned function is nowhere on the radar. Your options will gravitate around dynamic SQL or very complicated static queries. I’m afraid there is no free lunch on this topic.

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

Sidebar

Related Questions

The HTTP/1.1 specification ( RFC2616 ) defines a number of status codes that can
For a project I have a specification with formulas, I have to implement. In
I have read about partial methods in the latest C# language specification , so
I'm relatively new to the Component Object Model specification - I have a simple
I've got a copy of the Word document C# Language Specification Version 1.2 and
I have a function where I have a container which holds strings (eg vector<string>
The JPA (Java Persistence API) specification has 2 different ways to specify entity composite
According to the Java Language Specification : If there are any enclosing try statements
Does anyone know how to modify an existing import specification in Microsoft Access 2007
SNTP is a simplification of the full NTP specification. I'd like to use a

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.