I am trying to create an SP on a CDC enabled database. SP contain an update statement for CDC enabled table using UPDATETEXT command but CREATE PROCEDURE statement has generated an ERROR Message.
"UPDATETEXT is not allowed because the column is being processed by a concurrent snapshot or is being
replicated to a non-SQL Server Subscriber or Published in a publication allowing Data Transformation Services (DTS) or
tracked by Change Data Capture."
I have followed the instructions on a post that disable CDC for the table for which sp has command UPDATETEXT and then create SP and after sp creation re- enable CDC for that table
Question:
- Whats the reason behind this Error ?
- Will UPDATETEXT command effect logging in future? because we are thinking to use CDC for auditing change.
Best Answer
It is in the error message,
You cannot use it on columns tracked by CDC.
Testing
Create table & insert sample data
Test updatetext without CDC
This runs fine
Result
The 9th value was changed to 'C'.
Enable CDC on the db and table
Try to run the same query
The same error
By the way, updatetext might be removed in future versions, and
TEXT
,NTEXT
andIMAGE
datatypes are also deprecatedSource
What could you do?
I would advise to try and change the column to either
nvarchar(max)
,varchar(max)
orvarbinary(max)
depending on the deprecated datatype used, and then using.write
.Testing with text:
As it is now, I cannot use .Write since the datatype is text.
Changing the datatype and testing the query again, with CDC enabled. Alter table tablea alter column UpdateTextTest varchar(MAX)
Result:
the 10th value was also changed to 'c'.
Extra info
Readtext works with cdc
Result:
Writetext does not work with CDC
Error: