Yes, I saw that many do, unfortunately. You are right though: this is sneaky.
Typically, layer separation problems arise when mixing two adjacent layers โ you get business logic at the database level or presentation logic at the business level. But this completely skips the layer, placing the target with instructions on the user side, where it belongs from! Bound to be unshakable horror.
If villains are not convinced of such pleas for sanity, you can catch them for security reasons. Database-level functionality in stored procedures is unlikely to know how to avoid text for output in HTML or JS-string-literal, which leads to very likely script-injection hacks that lead to XSS attacks. For example, if the user calls himself "Brian von <script> steal (document.cookie) </script>" and which is roughly combined into the result of the HTML procedure of the stored procedure ...
source share