0

See my code below along with error message.

CREATE TRIGGER SubscriptionDescriptionNotes

ON [dbo].[Subscriptions]

AFTER INSERT, UPDATE

AS

UPDATE dbo.Subscriptions

SET [Description] = -- parse Parameter column and add to Description

                             [Parameters]  + Description

FROM [dbo].[Subscriptions] s

  WHERE s.[Parameters] LIKE '' --again parse parameter with condition what you want

Msg 402, Level 16, State 1, Procedure SubscriptionDescriptionNotes, Line 13 The data types ntext and nvarchar are incompatible in the add operator.

Alex K.
  • 171,639
  • 30
  • 264
  • 288
BMergen
  • 15
  • 1
  • 3
  • 1
    The datatypes of text and ntext have been deprecated since sql 2005. They are a serious pain to work with. You should move to (n)varchar(max) instead. Do you REALLY need to use max? Those datatypes can hold a LOT of data. I also, don't see you using the inserted or deleted virtual tables in here. As posted this will update the entire Subscriptions table every time this trigger fires. – Sean Lange May 11 '16 at 14:54
  • I agree with what Sean says, especially about updating the entire table. Your core logic is wrong. Beyond that, the problem you're facing is that [ntext doesn't support concatenation](http://stackoverflow.com/questions/1272416/concatenate-ntext-in-sql-server-2005). As it is you'll have to do something like `SET [Description] = CAST([Parameters] AS nvarchar(max)) + Description` or `SET [Description] = CAST([Parameters] + CAST(Description as nvarchar(max)) as ntext)` depending on which field is ntext. – Bacon Bits May 11 '16 at 14:58

0 Answers0