?
Solved

trigger with ntext value

Posted on 2009-05-11
4
Medium Priority
?
517 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 93

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 375 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
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…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…

840 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