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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T02:27:32+00:00 2026-06-02T02:27:32+00:00

This is how the stored procedure would be structured: [dbo].[getSp] ( @Color varchar(10) =

  • 0

This is how the stored procedure would be structured:

[dbo].[getSp] (
  @Color varchar(10) = Null,
  @Finish varchar(10) = Null,
  @Height varchar(10) = Null,
  @Type varchar(10) = Null,
  @Trim varchar(10) = Null,
  @Width varchar(10) = Null
)

This is how the data looks before searched..This data is incomplete, but as an example to get an idea. Every combination would be in here..

Color  |  Finish  |  Height  |   Type    |  Trim  |  Width  |
 Blue  |  Shiny   |   Tall   |  Toaster  | Normal |   3.5   |
(NULL) |  (NULL)  |  (NULL)  |  Toaster  | (NULL) |   3.5   |
(NULL) |  (NULL)  |   Tall   |  Toaster  |  Deco  |    4    |
(NULL) |  Shiny   |   Tall   |  Toaster  |  Deco  |    4    |
 Blue  |  Shiny   |  (NULL)  |  Toaster  |  Deco  |    4    |
(NULL) |  Shiny   |   Tall   |  Toaster  |  Deco  |    4    |
(NULL) |  Satin   |   Tall   |  Toaster  |  Deco  |    4    |
  Red  |  (NULL)  |   Tall   |  Toaster  |  Deco  |    4    |

The SELECT statement would have Type as the primary lookup field, so it would look something like this:

SELECT * FROM TABLE WHERE Type = @Type And
(

..... Confused about this part, 

)

But basically, I would like to run a stored procedure to only include those combinations, which are rows found in the table when called with only a part of the params, like this:

[getSp] 
@Color='Blue',
@Finish='Shiny',
@Type='toaster'

And the sp would ultimately return this (every combination)..

1. Blue Shiny Tall Toaster
2. Blue Shiny Toaster
3. Blue Tall Toaster
4. Blue Toaster
5. Tall Toaster
6. Shiny Toaster
7. Shiny Tall Toaster

So I am confused about how to structure the Where statement in the stored procedure to return every combination for ONLY those which you include in the stored procedure params, but the remaining params (like Width and Trim would be left out of the results and searching, would and when passed as NULL by default.

I’ve tried this without any luck…

SELECT * FROM TABLE WHERE 
Type = @Type AND
(
COLOR = COALESCE(@Color,COLOR) AND...
... for each other param
)

I’ve tried this without any luck…

SELECT * FROM TABLE WHERE 
Type = @Type AND
(
(Color = @Color OR COALESCE(@Color,COLOR) IS NULL) OR...
... for each other param
)

I’ve tried building the sql statement, but have failed as well.. Any suggestions would be helpful.

  • 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-02T02:27:34+00:00Added an answer on June 2, 2026 at 2:27 am

    This should meet your needs, if you provide a param then it uses it to filter otherwise it won’t:

    SELECT *
    FROM table_1
    WHERE (@Color IS NULL OR Color = @Color)
    AND (@Finish IS NULL OR Finish = @Finish)
    AND (@Height IS NULL OR Height = @Height)
    AND (@Type IS NULL OR Type = @Type)
    AND (@Trim IS NULL OR Trim = @Trim)
    AND (@Width IS NULL OR Width = @Width)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to write a stored procedure like this Create Proc dbo.GetApplicantsByIDs as Select
This stored procedure is supposed to : Take the userid and Date as input
I have this stored procedure: CREATE OR REPLACE PROCEDURE LIQUIDACION_OBTENER ( p_Cuenta IN NUMBER,
I have this stored procedure for Oracle: create or replace procedure bns_saa_message_get() <--- PROBLEM
Can anyone please point out what im doing wrong with this Stored Procedure please.
I have a mysql stored procedure from this ( google book ), and one
If I have this stored proc definition minus the body ALTER PROCEDURE sp_AlloctionReport(@where NVARCHAR(1000),
here's the stored procedure i wrote.In this proc p_subjectid is an array of numbers
IS this bit of code in PHP/mysql considered a stored procedure? $sql = 'SELECT
I have a stored procedure that logs some data, how can I call this

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.