May 24, 2012

sp_MSprofile_in_use (Transact-SQL MetaData) Definition

Please note: that the following source code is provided and copyrighted by Microsoft and is for educational purpose only.
The meta data is from an SQL 2012 Server.

I have posted alot more, find the whole list here.

Goto Definition or MetaData

Definition:

sys.sp_MSprofile_in_use(nvarchar @tablename
, int @profile_id)

MetaData:

 CREATE PROCEDURE sys.sp_MSprofile_in_use   
(
@tablename nvarchar(255),
@profile_id int
)
AS
begin
DECLARE @usage_count int

--
-- security check
-- only db_owner can execute this
--
if (is_member ('db_owner') != 1)
begin
raiserror(14260, 16, -1)
return (1)
end

IF @tablename IS NULL OR @profile_id IS NULL
return 1 ;

IF @tablename = 'MSsnapshot_agents'
SELECT @usage_count = count(*) FROM MSsnapshot_agents
WHERE profile_id = @profile_id
ELSE IF @tablename = 'MSlogreader_agents'
SELECT @usage_count = count(*) FROM MSlogreader_agents
WHERE profile_id = @profile_id
ELSE IF @tablename = 'MSdistribution_agents'
SELECT @usage_count = count(*) FROM MSdistribution_agents
WHERE profile_id = @profile_id
ELSE IF @tablename = 'MSmerge_agents'
SELECT @usage_count = count(*) FROM dbo.MSmerge_agents
WHERE profile_id = @profile_id
ELSE
SELECT @usage_count = 0

IF @usage_count = 0
RETURN -1
ELSE
RETURN 0
end

No comments:

Post a Comment

Total Pageviews