Using Triggers to Replace Scalar UDFs on Computed Columns


Your database is riddled with computed columns whose definition includes a scalar user-defined function. Even up to & including SQL Server 2019, which boasts faster scalar function processing, any table that includes a scalar function cause all access to that table to go single-threaded. In that case, a trigger can actually be a great replacement.

No, wait, come back. Triggers have a pretty bad reputation amongst the database community because:

You can pile a lot of work into them, leading to surprise slowdowns at scale You can hold locks open for a long time as you work through a lot