Check if your dynamic T-SQL statement is valid

I create this stored procedure and use in my scripts and codes.