日期:2014-05-17 浏览次数:20671 次
CREATE PROCEDURE dbo.sysmail_help_principalprofile_sp
@principal_id int = NULL, -- must provide id or name
@principal_name sysname = NULL,
@profile_id int = NULL, -- must provide id or name
@profile_name sysname = NULL
AS
SET NOCOUNT ON
DECLARE @rc int
DECLARE @principal_sid varbinary(85)
DECLARE @profileid int
exec @rc = msdb.dbo.sysmail_verify_profile_sp @profile_id, @profile_name, 1, 0, @profileid OUTPUT
IF @rc <> 0
RETURN(1)
IF (@principal_id IS NOT NULL AND @principal_id = 0) OR (@principal_name IS NOT NULL AND @principal_name = N'public')
BEGIN
IF (@principal_id IS NOT NULL AND @principal_id <> 0) OR (@principal_name IS NOT NULL AND @principal_name <> N'public')
BEGIN
RAISERROR(14605, -1, -1, 'principal') -- id and name do not match
END
SET @principal_sid = 0x00 -- public
IF (@profileid IS NOT NULL)
BEGIN
SELECT principal_id=0,
principal_name = N'public',
prof.profile_id,
profile_name=prof.name,
&n