Change Data Capture Error 14234
Change Data Capture Error 14234
SQL Server – Error While Enabling CDC on a Table The specified ‘@server’ is invalid (valid values are returned
by sp_helpserver)
Every environment is different and it is no doubt some of these environment changes can give you results that are
not expected. Recently one of my blog reader followed below blogs:
SQL SERVER – Introduction to Change Data Capture (CDC) in SQL Server 2008
SQL SERVER – Download Script of Change Data Capture (CDC)
and they reported that when he is trying to enable CDC for a table, he was getting below error:
Msg 22832, Level 16, State 1, Procedure sp_cdc_enable_table_internal, Line 623
Could not update the metadata that indicates table [HumanResources].[Shift] is enabled for Change Data Capture. The
failure occurred when executing the command ‘[sys].[sp_cdc_add_job] @job_type = N’capture”. The error returned was
22836: ‘Could not update the metadata for database AdventureWorks2014 to indicate that a Change Data Capture job has
been added. The failure occurred when executing the command ‘sp_add_jobstep_internal’. The error returned was 14234:
‘The specified ‘@server’ is invalid (valid values are returned by sp_helpserver).’. Use the action and error to determine the
cause of the failure and resubmit the request.’. Use the action and error to determine the cause of the failure and resubmit
the request.
So the best way to learn these new things is by exploring the events how it happened. Below is the script he was
using (taken from my blog)
-- You can run this stored procedure in the context of each database to enable CDC at database level.
USE AdventureWorks2014
GO
EXEC sys.sp_cdc_enable_db
GO
USE AdventureWorks2014
GO
EXEC sys.sp_cdc_enable_table
@source_schema = N'HumanResources',
@source_name = N'Shift',
@role_name = NULL
GO
First command was working fine. Error was raised by second command. I asked him to capture the profiler and
share with me. I found that first SQL Server get instance name using below query:
SELECT @server = CONVERT(SYSNAME,SERVERPROPERTY('ServerName'))
The value is then passed to create the job for CDC. In procedure sp_verify_jobstep, below is the condition which
was failing.
IF (@server IS NOT NULL) AND
Notice that this is the same error in error message (which I have highlighted) I asked him to check and he verified
that SQL Server name was changed but sp_dropserver and sp_addserver was not executed. Here is the command to
fix the issue. Please change the parameter values as per your SQL Instance.
sp_dropserver 'HostName\InstanceName_incorrect'
GO
GO
SELECT SERVERPROPERTY('ServerName')
If your SERVERPROPERTY('ServerName') is not any of the sysservers, then the fix is to change your computer
name to match one of those.
GO
sp_dropserver 'ABC'
GO
GO