How to view a stored function - SQL Server
select definition
from sys.sql_modules
where object_name(object_id) like 'functionName'
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'
--ShowStoredProcedures
select p.[type]
,p.[name]
,c.[definition]
from sys.objects p
join sys.sql_modules c
on p.object_id = c.object_id
where p.[type] = 'P'
--and c.[definition] like '%foo%'
ORDER BY p.[name]
___________
SELECT OBJECT_NAME(object_id) ProcedureName,
definition
FROM sys.sql_modules
WHERE objectproperty(object_id,'IsProcedure') = 1
ORDER BY OBJECT_NAME(object_id)