HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlModerate

Is it Possible to Overload SQL Server Functions?

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
overloadsqlpossibleserverfunctions

Problem

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?

Solution

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:

SELECT dbo.COUNT(1)
FROM dbo.SomeTable st
GROUP BY st.SomeCol;


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

Code Snippets

SELECT dbo.COUNT(1)
FROM dbo.SomeTable st
GROUP BY st.SomeCol;

Context

StackExchange Database Administrators Q#211449, answer score: 10

Revisions (0)

No revisions yet.