April 16, 2012

sp_cdc_enable_db (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_cdc_enable_db()

MetaData:

 create procedure [sys].[sp_cdc_enable_db]  
as
begin
declare @retcode int
,@containment tinyint
,@db_name sysname

-- Verify SQL Server edition
-- CDC is restricted to Eval, Enterprise and Developer editions
IF (sys.fn_MSrepl_editionid () not in (30,31))
BEGIN
DECLARE @edition sysname
SELECT @edition = CONVERT(sysname, SERVERPROPERTY('Edition'))
RAISERROR(22988, 16, -1, @edition)
RETURN (1)
END

-- Verify caller is authorized to enable change data capture for the database
if (isnull(is_srvrolemember('sysadmin'),0) = 0)
begin
raiserror(22902, 16, -1)
return 1
end

--
-- Contained Database check (Replication is not yet supported on contained databases)
-- If the current database is a contained database, then we error out.
--
SELECT @containment=containment FROM sys.databases WHERE
database_id = db_id()
if (@containment != 0)
BEGIN
set @db_name = db_name()
RAISERROR(12839, 16, -1, @db_name)
RETURN(1)
END

exec @retcode = sys.sp_cdc_enable_db_internal

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

return 0
end

No comments:

Post a Comment

Total Pageviews