Solved

trigger with ntext value

Posted on 2009-05-11
4
424 Views
Last Modified: 2012-05-06
I have a trigger,
But am having a problem updating the comp_notmaintained value as its of type ntext.
If I remove this value it works with the other two.

Please can anyone suggest a workaround?

Many thanks,

Mim
CREATE trigger [trg_updatecomp]

  on [dbo].[Installed]

 for update

as

  update Company

    set comp_inststatus

      = i.inst_status, comp_expirydate = i.inst_expirydate, comp_notmaintained = i.inst_notmaintained

from Installed q 

join inserted i

on i.inst_companyid = q.inst_companyid

Open in new window

0
Comment
Question by:MimUK
4 Comments
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 24354557
you cannot update the text column with an update statement, you need to use UPDATETEXT /WRITETEXT
0
 
LVL 92

Expert Comment

by:Patrick Matthews
ID: 24354573
MimUK said:
>>Please can anyone suggest a workaround?

If you are using SQL Server 2005 or later, use nvarchar(max) instead of ntext.
0
 

Author Comment

by:MimUK
ID: 24354577
Please could you help with what I need to replace in the trigger.
i cannot change the column type as its fixed in the application

Mim
0
 
LVL 22

Accepted Solution

by:
dportas earned 125 total points
ID: 24357521
This should work:

CREATE TRIGGER [trg_updatecomp]
  ON [dbo].[Installed]
 FOR UPDATE
AS
  UPDATE Company
    SET comp_inststatus
      = i.inst_status, comp_expirydate = i.inst_expirydate, comp_notmaintained = q.inst_notmaintained
  FROM Installed q
  JOIN inserted i
  ON i.inst_companyid = q.inst_companyid
  JOIN Company
  ON i.inst_companyid = Company.inst_companyid ;
GO

0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now