문제

I have a table in my SQL Server 2005 database, which has a field with the datatype NTEXT. This table is replicated in a merge-replication with a lot of SQLCE-subscriptions.

I have tried to add an ON INSERT trigger to this table to process the NTEXT-field. But I got this error:

Cannot use text, ntext, or image columns in the 'inserted' and 'deleted' tables.

On my researches I found several postings that NTEXT is deprecated and I should change to NVARCHAR(MAX). But I can't do this without recreating the snapshot, which is quite a problem for the people working with the devices (because of dataamount and time).

Is there a workaround for the insert-trigger to handle the datatypes?

This is where the error is thrown:

DECLARE c1 CURSOR FOR SELECT ControlValue FROM INSERTED
도움이 되었습니까?

해결책

You can do this by reading the data from the underlying table, joining on INSERTED.

This is the workaround:

DECLARE c1 CURSOR FOR SELECT t.ControlValue 
from INSERTED i 
  INNER JOIN TableName t on i.PrimaryKey = t.PrimaryKey

Essentially you need to join the inserted and/or deleted pseudo-tables onto the underlying table and read the NTEXT, TEXT or IMAGE data from the underlying tables.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top