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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T16:21:54+00:00 2026-06-11T16:21:54+00:00

I am working in a SQL Server environment, heavy on stored procedures, where a

  • 0

I am working in a SQL Server environment, heavy on stored procedures, where a lot of the procedures use 0 and ” instead of Null to indicate that no meaningful parameter value was passed.

These parameters appear frequently in the WHERE clauses. The usual pattern is something like

WHERE  ISNULL(SomeField,'') = 
    CASE @SomeParameter 
        WHEN ''  THEN ISNULL(SomeField,'')
        ELSE @SomeParameter
    END

For various reasons, it’s a lot easier to make a change to a proc than a change to the code that calls it. So, given that the calling code will be passing empty strings for null parameters, what’s the fastest way to compare to an empty string?

Some ways I’ve thought of:

@SomeParameter = ''

NULLIF(@SomeParameter,'') IS NULL

LEN(@SomeParameter) = 0

I’ve also considered inspecting the parameter early on in the proc and setting it to NULL if it’s equal to ”, and just doing a @SomeParameter IS NULL test in the actual WHERE clause.

What other ways are there? And what’s fastest?

Many thanks.

  • 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-11T16:21:55+00:00Added an answer on June 11, 2026 at 4:21 pm

    Sorting out the parameter at the start of the proc must be faster than multiple conditions in a where clause or using a function in one. The more complex the query, or the more records that have to be filtered, the greater the gain.

    The bit that would scare me is if this lack of nullability in the procedure arguments has got into the data as well. If it has when you start locking things down, your queries are going to come back with the “wrong” results.

    If this product has some longevity, then I’d say easy is the wrong solution long term, and it should be corrected in the calling applications. If it doesn’t then may be you should just leave it alone as all you would be doing is sweeping the mess from under one rug, under another…

    How are you going to test these changes, the chances of you introducing a wee error, while bored out of your skull making the same change again and again and again, are very high.

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

Sidebar

Related Questions

I'm working on SQL server 2005 and I have a very simple stored procedure:
I wan't to use Sql Server 2008 as production environment with provider System.Data.SqlClient and
I'm working with SQL Server and Datatables in a PHP environment; I've researched a
Working environment is SQL Server 2000. I have a table with no indexes, no
I'm working with 2 related tables in a Microsoft SQL Server 2008 environment which
Environment I'm working on a C++ application that uses SQL Native Client 9.0 to
I have been working with SQL Server as a Developer a while. One thing
I am working on SQL SERVER 2008 & 2008 R2. How can I rename
I'm working on SQL SERVER 2008 R2 Performance tunning part but I'm new in
I am working on sql server where i want to save html code into

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.