March 27, 2007 at 10:54 am
I am getting this error when @ReferenceRange is null.
"Invalid length parameter passed to the SUBSTRING function. The statement has been terminated."
CASE
WHEN @ReferenceRange IS NULL THEN NULL
ELSE LEFT(@ReferenceRange , CHARINDEX('-', @ReferenceRange )-1)
END,
CASE
WHEN @ReferenceRange IS NULL THEN NULL
ELSE RIGHT(@ReferenceRange , LEN(@ReferenceRange ) - CHARINDEX('-', @ReferenceRange ))
END,
How do I get around this? Do I have to push the parsing to a function where I do a null test first?u
March 27, 2007 at 11:14 am
Sounds like maybe it isn't null but maybe blank. Try changing both lines to this
WHEN NullIf(@ReferenceRange,'') IS NULL THEN NULL
March 27, 2007 at 11:30 am
It worked, thx! Is NULLIF new in 2005?
April 1, 2007 at 2:14 am
No. It is also available in 2000.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply