Select @Script returns NULL instead of @Script SQL

Solution 1:

You can interchange NULL for meaning 'unknown'

When you concatenate unknown to a string, the result is also unknown (if you add an unknown quantity to a known quantity you now have an unknown quantity). You need to use IsNull()

try

+ CAST(isnull(@Type,'0') AS VARCHAR(10)) +