Is it possible to overload a sql server function? Either a scalar, like ltrim, or an aggregate function, like count?

Even if this was a really, really, bad idea. Is it possible?

Somewhat of a duplicate of T-SQL User defined function overloading? I would say it isn't 100% a duplicate, since that was for 2005 version. Maybe this has changed?


1 Answer 1


There is no straight-forward way of carte-blanche overriding a built-in function in SQL Server.

You can kind of fake it by creating a function with the same name in a different schema, then calling that function with the schema name, as in:

FROM dbo.SomeTable st
GROUP BY st.SomeCol;

However, this is quite likely to cause more confusion than it is worth.

  • 6
    And if you're going to have to change the code to use the schema name anyway, you might as well change it to refer to a differently-named user function.
    – BradC
    Commented Jul 5, 2018 at 15:07
  • 1
    Completely agree, @BradC - overall it's just a bad idea to try overloading in SQL Server.
    – Hannah Vernon
    Commented Jul 5, 2018 at 15:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.