Hi Steven,
Thank alot for your advise.
I am just wondering why when I pass '' inside my parameter of my SP,
the line "IF(LEN(@par1) > 0)" is true, The @par1 is length of 2
insteads of 0.
Do you know why ?
I am told use default of NULL insteads.
>Hi,
> I don't think "if(len(@para1) = 2) to check for empty parameter"
>is a good idea. Recommend "if(isnull(@para1,'') = ''" instead,
>then no matter which the @par1 is null or empty, it always returns correct value.Of course,you have to ensure any invisible characters,e.g.
>char(13)+char(10) are excluded from the parameter passed in,as Sergey mentioned.
> Reference to codes below:
>
> declare @par1 varchar(100)
>select @par1=space(0)
>select len(@par1), case when isnull(@par1,'')='' then 'True' else 'False'end
>select @par1=space(2)
>select len(@par1), case when isnull(@par1,'')='' then 'True' else 'False'end
>
>
Best Regards
Virusim