Query to check Default Database Mail profile in SQL Server?

Query to check Default Database Mail profile in SQL Server?

Query to check default Database Mail profile in SQL Server?

SELECT TOP 1 name
FROM msdb.dbo.sysmail_profile p
JOIN msdb.dbo.sysmail_principalprofile pp ON pp.profile_id = p.profile_id AND pp.is_default = 1

Suppose if you want to take the value in a variable then you can use the below query:

DECLARE @defaultProfileName NVARCHAR(100)=''
SELECT TOP 1 @defaultProfileName=name
FROM msdb.dbo.sysmail_profile p
JOIN msdb.dbo.sysmail_principalprofile pp ON pp.profile_id = p.profile_id AND pp.is_default = 1




You may also like

No comments:

If you have any queries regarding the article or in performing something in Microsoft SQL Server then please let me know.