• Be careful with omitting information in your SQL.

    For example, it is good practice to explicitly specify the nullability of your columns.

    Had ANSI_NULL_DFLT_OFF for the session, the insert would fail.

    Msg 515, Level 16, State 2, Line 9

    Cannot insert the value NULL into column 'IsAvailable', table 'tempdb.dbo.#Test_______________________________________________________________________________________________________________000000000044'; column does not allow nulls. INSERT fails.

    SET ANSI_NULL_DFLT_OFF (Transact-SQL)

    Also, in the CONVERTS, you should specify the size to avoid issues and misunderstandings.

    convert(varchar(30), colxyz)

    instead of

    convert(varchar, colxyz)

    Best Regards,

    Chris Büttner