473,385 Members | 2,005 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

ntext and update/insert triggers

SQL Server 2000 : I have a series of tables which all have the same
structure. When any of these tables are modified I need to syncrhonise
all of those modifications with one other table wich is a sort of merge
of the individual tables with one extra column.

For most of these tables this is not a problem. The problem arrives
when one of the tables has an ntext column which obviously can not be
used in an update or insert trigger.

Here's an example of one of them:

CREATE TABLE tblImages(
ID INT IDENTITY(1,1) PRIMARY KEY,
Inventory nvarchar(8) NOT NULL,
Coll nvarchar(8) NOT NULL,
ImageFile nvarchar(128) NOT NULL,
ImageNotes ntext NULL,
TS timestamp NULL
CONSTRAINT U_Images UNIQUE NONCLUSTERED (ItemCode, Inventory, Coll,
ImageFile)

I then had created an update trigger which looked like this:

CREATE TRIGGER COLLNAME_UTRIGGER ON COLLNAME_Images
FOR UPDATE
AS
BEGIN
UPDATE tblImages SET
Inventory = inserted.Inventory,
Coll = 'COLLNAME',
ImageFile = inserted.ImageFileName,
FROM inserted INNER JOIN tblImages ON inserted.ItemCode =
tblImages.ItemCode AND
inserted.Invventory = tblImages.Invventory AND tblImages.Coll =
'COLLNAME' AND
inserted.ImageFileName = tblImages.ImageFile

UPDATE tblImages
SET ImageNotes=inserted.Notes
FROM inserted INNER JOIN tblImages ON inserted.ItemCode =
tblImages.ItemCode AND
inserted.Inventory= tblImages.Inventory AND tblImages.Coll =
'COLLNAME' AND
inserted.ImageFileName = tblImages.ImageFile
END " & vbCrLf)

The first update in my trigger, be it an update or insert trigger,
works fine. It crashes with the "Cannot use text, ntext or image
columns in the 'inserted' or 'deleted' tables." error in the second
part.

I have read various messages through the Internet on this and several
of them reference using INSTEAD OF triggers and views. I have never
used those before as this is my first work with SQL 2000. None of the
examples of INSTEAD OF triggers I have seen yet use the actual inserted
tables and I haven't quite understood how to use them correctly.

Can someone help me with the basic syntax as this trigger is one of
several that I am going to have to get working.

Thank you in advance for any help, assistance, suggestions or
"direction pointing" you may provide.

Jul 23 '05 #1
1 6282
On 13 May 2005 06:17:29 -0700, Derek Erb wrote:

(snip)

Hi Derek,

I don't really understand your question. First, you write that the
tablles all have the same structure, then you indicate that one of the
tables has an ntext column. If they are all the same structure, wouldn't
they all have this ntext column?

Also, you are storing loads of redundant data. I suggest that you drop
all tables except the merge table (that holds all data from all other
tables plus the extra column). Then create views to mimic the old
tables. I guess that this would solve most if not all your problems!

Finally, to answer your question: ntext and image columns are not
available in the inserted pseudotable (except when you use an INSTEAD OF
trigger, but I wouldn't recommend them in your case). The workaround is
to fetch the ntext or image data from the base table by joining the
inserted pseudotable to the base table on all the key columns.

Best, Hugo
--

(Remove _NO_ and _SPAM_ to get my e-mail address)
Jul 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: KathyB | last post by:
Hi, I've been reading all sorts of info on the ntext field. I need this to store xml documents in sql server via a stored proc. Because of its size, I apparently can not use SET (as in UPDATE)...
2
by: KathyB | last post by:
Hi, I've read conflicting articles on updating an ntext field in a column. My ntext field will exceed 8,000 characters (typically twice that size -- but just a text string). One article (I...
1
by: Gent | last post by:
am using FOR UPDATE triggers to audit a table that has 67 fields. My problem is that this slows down the system significantly. I have narrowed down the problem to the size (Lines of code) that need...
1
by: Bill | last post by:
Hi all, I have an asp page that writes to an ntext field in SQL Server 2000. All was going well until I had to put in a section of text greater than 8000 bytes. Then I got a timeout error and...
5
by: Cally | last post by:
Hello, I would like to convert a field from ntext field found in one database table to float field found in another database table. The reason why I want to do this is a long one. I have...
2
by: igorsl | last post by:
Hi, I have a problem to insert(update) a long text (more than 64K) into SQL 2000 (datatype - 'text'). It cuts the data and insert only 64K. MSDN says: "When the ntext, text, and image data values...
18
by: Bill Smith | last post by:
The initial row is inserted with the colPartNum column containing a valid LIKE pattern, such as (without the single quotes) 'AB%DE'. I want to update the column value with the results of a query...
2
by: Igor | last post by:
Is there a way to transfer ntext data from one table to another? I tried this UPDATE SET = (SELECT FROM WHERE =1) WHERE = 1;
1
by: abhi81 | last post by:
Hello All, I have a table on which I have created a insert,Update and a Delete trigger. All these triggers write a entry to another audit table with the unique key for each table and the timestamp....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.