[Solved] syntax error while executing sql [closed]


Try this, you are missing “+”s and “‘”s:

DECLARE @SQL NVARCHAR(MAX) = N'
    SELECT
        CASE WHEN ISNULL(10, '''') = '''' AND ISNULL('''', '''') = '''' THEN ''''
        ELSE CONVERT(NVARCHAR(5), 10) + ' + ''' To ''' + ' + CONVERT(NVARCHAR(5), 20)
    END;';
SELECT @SQL;
EXEC(@SQL);

1

solved syntax error while executing sql [closed]