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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T19:16:35+00:00 2026-06-10T19:16:35+00:00

I read this: How do I check if a Sql server string is null

  • 0

I read this: How do I check if a Sql server string is null or empty but it not helped me in this situation.

The piece of code from my stored procedure:

IF (@item1 IS NOT NULL) OR (LEN(@item1) > 0)
        SELECT @sql = 'SELECT * FROM TEST1'
    ELSE
        SELECT @sql = 'SELECT * FROM TEST2'
 PRINT @sql;

@item1 is NVARCHAR(1000) type.

When execute this stored procedure, I provided the value for item1

EXEC    [dbo].[my_proc]
        @item1 = N''

it shows

SELECT * FROM TEST1 // it is correct if @item1 = N'some'

instead of

SELECT * FROM TEST2

It is somewhere a function in sql to verify if a string is null or empty OR I made somewhere a mistake ?

Like in C# -> string.IsNullOrEmpty(myValue)

  • 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-10T19:16:36+00:00Added an answer on June 10, 2026 at 7:16 pm

    that is the right behavior.

    if you set @item1 to a value the below expression will be true

    IF (@item1 IS NOT NULL) OR (LEN(@item1) > 0)
    

    Anyway in SQL Server there is not a such function but you can create your own:

    CREATE FUNCTION dbo.IsNullOrEmpty(@x varchar(max)) returns bit as
    BEGIN
    IF @SomeVarcharParm IS NOT NULL AND LEN(@SomeVarcharParm) > 0
        RETURN 0
    ELSE
        RETURN 1
    END
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this file which I need to read the first bytes to check
I read this code in a library which is used to display a bitmap
I recently moved a database from a 'SQL Server 2005 SP1' instance to 'SQL
I've got a problem with multiple deadlocks on SQL server 2005. This one is
I'm not a DB guy, but I've been hacking away at this one for
Okay so I read this post http://facebook.stackoverflow.com/questions/10373897/deleting-a-previosly-posted-article-with-opengraph-or-check-if-said-article-has but I'm using the news.reads action type.
I read this question in stackoverflow. The excerpt answer provided by bbum is below:
I read this post where the author advices to store session files in a
I read this article : http://lwuit.blogspot.in/2008/06/lightweight-text-input-in-lwuit.html This article talks of autocomplete textfield embedded on
I read this article on how to use keytool to generate CSRs for your

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.