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)