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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T22:58:33+00:00 2026-06-08T22:58:33+00:00

I have a stored procedure as shown below; when I pass NULL for Gkol

  • 0

I have a stored procedure as shown below; when I pass NULL for Gkol I want it to be changed to the minimum possible amount (that exists in the table), but it does not happen – why is that?

ALTER PROCEDURE sp_vUnitsUnitTejariGetFilteredUnitDetail
    (@UnitFB BIT,
     @UnitWithCooking BIT,
     @MMofidFrom FLOAT = NULL,
     @MMofidTo FLOAT = NULL,
     @GKolFrom FLOAT = NULL,
     @GKolTo FLOAT = NULL)
AS
BEGIN
    DECLARE @MMofidCalculative BIT
    DECLARE @GKolCalculative BIT

    IF (@MMofidFrom IS NULL)
        SELECT @MMofidFrom = MIN(MMofid) 
        FROM vw_PSA_UnitsUnitTejari

    IF (@MMofidTo IS NULL)
        SELECT @MMofidTo = MAX(MMofid) 
        FROM vw_PSA_UnitsUnitTejari

    IF (@GKolFrom IS NULL)
        SELECT @GKolFrom = MIN(GKol) 
        FROM vw_PSA_UnitsUnitTejari

    IF (@GKolTo IS NOT NULL)
        SELECT @GKolTo = MAX(GKol) 
        FROM vw_PSA_UnitsUnitTejari

    SELECT * 
    FROM vw_PSA_UnitsUnitTejari 
    WHERE UnitTypeID = 1
      AND UnitStateID = 1
      AND UnitFB = ISNULL(@UnitFB, UnitFB)
      AND UnitWithCooking = ISNULL(@UnitWithCooking, UnitWithCooking)
      AND MMofid BETWEEN @MMofidFrom AND @MMofidTo
      AND GKol BETWEEN @GKolFrom AND @GKolTo
END
  • 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-08T22:58:35+00:00Added an answer on June 8, 2026 at 10:58 pm

    I figured out why it was not working, the problem was in the last if block

    if(@GKolTo is not null)
    

    I removed NOT and everything went well, thanks everyone

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

Sidebar

Related Questions

I have the MYSQL stored procedure defined as shown below: DROP PROCEDURE IF EXISTS
I have a stored procedure that has the parameter: @desk VARCHAR(50) I want to
I have this stored procedure that I want to use for my SAP crystal
I have created a stored procedure shown below ,how will i call this from
I have a stored procedure that gives a friendly enough error that I want
I have a stored procedure that gets a list of items, sorts and applies
I have a method that calls a stored procedure. It uses the employee number
Using SQLServer 2008 I currently have a function that implements functionality as shown below
I have written a Stored Procedure as shown , which will be responsible to
I have a stored procedure that returns multiple columns. like colA colB colC ....

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.