In a dynamic SQL server query i want to build a dynamic insert script based on other table.
SELECT 'INSERT INTO MyTable(column) VALUES ' + Concat ('(',ISNULL(''''+ ColumnValue+'''', 'NULL'), ')' ) from myOriginalTable
and I want it to return 'NULL' as a varchar value if the column value is null in the original table.
But when column value is null:
(basically in SSMS) : select ISNULL(''''+ NULL+'''', 'NULL')
then the returned value is 'NUL' varchar instead of NULL, and i don't know why.
When i try the query outisde dynamic context it works:
select isnull(NULL,'NULL')
Is this a feature or a bug?
EDIT
This is not table definition related, to reproduce the issue just run select ISNULL(''''+ NULL+'''', 'NULL')
in SSMS or find the result from an online platform