Version: SQLServer 8
I would like to view the contents of a stored function in sqlserver, i.e. what exactly the function is doing.
None of the options listed here work for me. There doesn't appear to be any database/table called sys.objects. I was able to query the information_table.routines table, but that does not contain the function that I am looking for. My function is located in:
DBName.dbo.functionName
How can I view the contents of this function?
You can use sp_helptext command to view the definition. It simply does
Displays the definition of a user-defined rule, default, unencrypted Transact-SQL stored procedure, user-defined Transact-SQL function, trigger, computed column, CHECK constraint, view, or system object such as a system stored procedure.
E.g;
EXEC sp_helptext 'StoredProcedureName'
EDIT:
If your databases
or server
are different then you can do it by specifying them as well
EXEC [ServerName].[DatabaseName].dbo.sp_helptext 'storedProcedureName'
select definition
from sys.sql_modules
where object_name(object_id) like 'functionName'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With