Viewing and Modifying User-Defined Functions

Besides using T-SQL commands to create functions, you can also use them to view and modify functions. You can get information by using the provided system procedures and queries against system views. The following sections describe these methods.

Using T-SQL to View Functions

There are multiple methods to view the source code for a user-defined function. One way is to use the sp_helptext procedure:

use AdventureWorks2012goexec sp_helptext getonlydategoText--------------------------------------------------------------------CREATE FUNCTION getonlydate ()RETURNS datetimeASBEGIN   RETURN (select convert(datetime, convert(date, getdate())))END

Note

To display the source ...

Get Microsoft® SQL Server 2012 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.