SQL: Calling a Scalar UDF with EXEC
Most SQL Server developers are aware that the EXEC statement can be used to:
- Execute a stored procedure (system, user-defined, extended)
- Execute some dynamic SQL
And most understand that you can SELECT from a scalar user-defined function.
But the option that many people don’t seem to be aware of, is that you can also use EXEC to call a scalar function.
I remember noticing this in the documentation for the EXEC command some years back. Prior to that, it had never dawned on me that you could use EXEC to call a scalar UDF. It’s also in the oldest documentation that I was able to check, so I’d say it’s worked for a long time.
2026-04-12