The two issues:1. SQL Server effectively moves all DECLARE statements to the place of the first DECLARE in script that leads to unexpected script result. This implicit movement affects the moved variable's collation in case of DB is switched with USE statement and the new DB have different collation.2. SQL Server analyses variable collation in IS NULL clause where it is not necessary. We should not use a collation to check variable for NULL.