none
Where can I actually find where the TRIM function is defined in SQL Server Management Studio RRS feed

  • Question

  • I'm pretty sure that SQL Server defined functions are located somewhere within the [msdb] or the [master] Database. Where can I find where the TRIM function is actually defined within SQL Server and SQL Server Management Studio?

    Thanks for your review and am hopeful for a reply.

    Friday, January 11, 2019 2:45 PM

All replies

  • I'm pretty sure that SQL Server defined functions are located somewhere within the [msdb] or the [master] Database.

    Nope, incorrect assumption. Some functions are, others are native code or .Net.

    Friday, January 11, 2019 2:59 PM
  • No, builtin functions are not stored in any database, but they are defined inside the engine.

    You may be thinking of system stored procedures. Most of these are stored in the resource database, which is hidden. You can still get the text of these functions by as in this example:

    sp_helptext 'sys.sp_who'

    Sometimes this will return "(server internal)", since they are implemented in C++.

    There are also some functions in the resource databases, but these are functions you have to call with two-part notation, for instance:

    SELECT * FROM sys.fn_helpcollations()


    Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

    Friday, January 11, 2019 4:28 PM
  • I usually debug the statement with single step and see if the debugger will step into the function or stored procedure. If I does not then I know it is internally defined and the code is not available for me to view. 
    Monday, January 14, 2019 2:36 PM