It looks like a 2nd variable in an expression is determining the maximum length of my 1st variable.
An example is easier to explian:
DECLARE @MyDest AS NVARCHAR(MAX) = 'Some long text, for testing'; DECLARE @MySrc AS NVARCHAR(6) = ''; SELECT @MyDest = ISNULL(NULLIF(@MySrc, N''), @MyDest); SELECT @MyDest;
The result is
'Some l' while I would expect
'Some long text, for testing'.
This is a simplified version of a more complicated bug I'm trying to fix. Is this a bug in SQL server or should I be doing this differently?