May 7, 2012

sp_MScdc_ddl_event (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_MScdc_ddl_event(xml @EventData)

MetaData:

 create procedure sys.sp_MScdc_ddl_event  
(
@EventData xml
)
as
begin
declare @retcode int
,@ddl_authorized bit

-- if CDC is not enabled for this db, don't do anything
if (sys.fn_cdc_is_db_enabled() != 1)
begin
return 0
end

-- Determine whether the caller is authorized before switching to dbo
-- Note: We don't want to prevent DDL that does not impact cdc behavior.
-- Since we can't determine immediately whether we are interested
-- in the DDL event or not, we simply retain the authorization
-- information so it can be checked later, if needed.
set @ddl_authorized = 1
if (isnull(is_srvrolemember('sysadmin'),0) = 0)
and (isnull(is_member('db_owner'),0) = 0)
and (isnull(is_member('db_ddladmin'),0) = 0)
begin
set @ddl_authorized = 0
end

-- Execute logic using an internal stored procedure that executes as 'dbo'
exec @retcode = sys.sp_cdc_ddl_event_internal @EventData, @ddl_authorized

if (@@error <> 0) or (@retcode <> 0)
begin
return 1
end

return 0
end

No comments:

Post a Comment

Total Pageviews