If I understand you correct then you want it to return 00000000 both if LEN(@Pattern) is less then 1 and @Pattern is null?
There are many ways to do this, and depending on how "pretty" you want the solution. But the easiest way would properly be to just assign a value of '' if your pattern is null, so something like this:
Code:IF @Pattern IS NULL SET @Pattern = '' SELECT CASE WHEN LEN(@Pattern) > 1 THEN @Pattern ELSE '00000000' END




Reply With Quote