Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where to find stored procedure msdb.dbo.sp_send_dbmail in SQL Server

I need to look at the code for stored procedure msdb.dbo.sp_send_dbmail in SQL Server. Could someone tell me where to look for the stored procedure in SQL Server Management Studio 2008.

like image 362
superbun1 Avatar asked Sep 06 '11 16:09

superbun1


3 Answers

Right there:

enter image description here

As the name already tells you - it's in the msdb database (which is under the System Databases), and the stored proc can be found under Programmability > System Stored Procedures

like image 67
marc_s Avatar answered Nov 04 '22 22:11

marc_s


USE msdb;
GO

sp_helptext 'dbo.sp_send_dbmail';

OR

USE msdb;
GO

SELECT definition 
    FROM sys.sql_modules 
    WHERE object_id = OBJECT_ID('dbo.sp_send_dbmail');
like image 35
Joe Stefanelli Avatar answered Nov 04 '22 22:11

Joe Stefanelli


From the Object Explorer node for your instance expand...

Databases -> System Databases -> msdb -> Programmability -> 
              Stored Procedures -> System Stored Procedures

Or (having seen Joe's answer) one non UI method

use msdb;

SELECT object_definition(object_id('dbo.sp_send_dbmail')) 
AS [processing-instruction(x)] FOR XML PATH('')
like image 38
Martin Smith Avatar answered Nov 04 '22 21:11

Martin Smith