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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T08:09:59+00:00 2026-06-14T08:09:59+00:00

I am using SQLServer 2008 and came across this problem. I have a function

  • 0

I am using SQLServer 2008 and came across this problem. I have a function where a user can select multiple dates from a menu. They also have the option to tick a checkbox ‘select all dates’.

If they select the checkbox my query should only return results in the given date. Thus execution a WHERE-clause.
If they did not select the checkbox but selected one or more dates; the query should be executed with a where clause.

I have 2 parameters for this.
-SelectedDates(eg. ‘2012-11-15′,’2012-11-15’)
-AllDates (‘X’ or ”)

Normally the query whould look like this:

SELECT * FROM x
WHERE x.date in ([Param.1])

So my question: how do I adapt the query in case the WHERE-clause is not needed.

FYI: the [Param.1] notation is used in the environment I am working in.

  • 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-06-14T08:10:00+00:00Added an answer on June 14, 2026 at 8:10 am

    simple, use a OR clause, if alldates is checked it will return data from all dates like this:

    SELECT * FROM x
    WHERE x.date in ([Param.1]) OR ([Param.2]) = 'X'
    

    if Param.2 is checked (‘X’) it will ignore the result of the first condition cause you are using the OR clause.

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

Sidebar

Related Questions

I'm using SQLServer 2008 and if I perform the following query: SELECT * FROM
Using SQLServer 2008 I currently have a function that implements functionality as shown below
I am using SQLSERVER 2008 R2. I have a procedure and want to run
Using SQL Server 2008. I have multiple Locations which each contain multiple Departments which
I'm using SQLServer 2008. Say I have a recursive hierarchy table, SalesRegion, whit SalesRegionId
I have developed a s/w using acces and sqlserver 2008 and now trying to
Using SqlServer 2008, I have a temp table (#tmpAllSales) that captures all sales for
I am using sqlserver 2008, How can I calculate the total memory occupied by
I am using SQLServer 2008. I have a table X with field Y that
I'm using Castle project ActiveRecord and SqlServer 2008 I wanna do this : ActiveRecordMediator<Question>.FindAll();

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.