• Even if that is what you intended (it often isn't) ALWAYS EXPLICITLY USE BEGIN/END with IF/ELSE constructs:

    ALWAYS is a bit strong. I'm not going to start replacing

    if object_id('tempdb..#tmp', 'U') is not null

    drop table #tmp

    with this

    if object_id('tempdb..#tmp', 'U') is not null

    begin

    drop table #tmp

    end

    in my code. SQL devs should know this stuff.

    If you know that the people who are going to be maintaining the code are not that proficient, then maybe. But nonetheless, the problems you mention should be sieved out during testing.

    If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.