Basing on the information on MSDN, I wrote a small script to remove the profile and account
--Choose the profile you want to remove by executing the command
SELECT * FROM msdb.dbo.sysmail_profile
--Choose the account you want to remove by executing the command
SELECT * FROM msdb.dbo.sysmail_account
Declare @profile_name varchar(20)='YourSelectedProfile'
Declare @account_name varchar(20)='YourSelectedAccount'
IF EXISTS (SELECT 1 FROM msdb.dbo.sysmail_profile WHERE name = @profile_name)
BEGIN
Print('The specified Database Mail profile already exists. We will delete it');
EXECUTE msdb.dbo.sysmail_delete_profile_sp @profile_name = @profile_name ;
END;
IF EXISTS (SELECT 1 FROM msdb.dbo.sysmail_account WHERE name = @account_name)
BEGIN
Print('The specified Database Mail account already exists. We will delete it') ;
EXECUTE msdb.dbo.sysmail_delete_account_sp @account_name = @account_name ;
END;
Refer:
http://technet.microsoft.com/en-us/library/ms186303(v=sql.105).aspx
http://technet.microsoft.com/en-us/library/ms176086(v=sql.105).aspx
0 comments:
Post a Comment