• In the WHERE clause you have:

    (sobj.name = @i_Table_Name or @i_Table_Name = '')

    Since @i_Table_Name is defined as sysname, you might want to use N'' instead of just ''.

    BTW did you consider using

    (sobj.name like @i_Table_Name )

    instead, thus allowing for wildcards and then covering the empty string with N'%' instead of just N''?

    I often find that explicit is better than implicit.

    Gerald Britton, Pluralsight courses