Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

For the sake of leaning and exploring, I'd like to look at how some of the system functions are built. Is there a way to do this in sql server 2008 or R2?

I've tried sp_helptext 'Sum' but I get an error saying that the resource cannot be found.

share|improve this question
up vote 2 down vote accepted

I don't think Sum is stored as a T-SQL function in your system that you could "peek" into. That's most likely code deep inside the SQL Server core.

As a proof - you can e.g. get the body of other system stored functions using sp_helptext:

sp_helptext 'sys.fn_isrolemember'

That works just fine - so that leads me to believe that Sum isn't a stored function as such.

share|improve this answer
Maybe functions like sum are built using the clr integration? – Brian Dishaw Feb 10 '12 at 14:21
@BrianDishaw: there are newer options that are indeed built using the SQL-CLR (things like the HierarchyID type and its operations) - but I'm pretty sure sum is so common that it's in the SQL Server core code base. – marc_s Feb 10 '12 at 14:22

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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