Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 update trigger on ntext

Author  Topic 

kapilarya
Yak Posting Veteran

86 Posts

Posted - 2005-08-11 : 08:06:06
is this possible to check update trigger on ntext fields

Kapil Arya

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-08-11 : 08:14:52
you can have trigger on the table that has the ntext field, but there'll be no values in inserted, updated or deleted pseudo tables for that field.

Go with the flow & have fun! Else fight the flow
Go to Top of Page

kapilarya
Yak Posting Veteran

86 Posts

Posted - 2005-08-11 : 08:28:19
actually i have 10 columns in employee table which are text field, and i need these feilds for auditing. and for auditing i am using triggers. but triggers doesnot allow auditing on text fields. is there any possible way of auditing on text fields.

Kapil Arya
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-08-11 : 08:31:27
you can stil have the trigger and inside select the data from the table:
if you have the id in the table say int then

insert into auditTable (id, text1, text2, ...)
select t1.id, t1.text1, t1.text2, ....
from MyTable t1 join inserted i on t1.id = i.id



Go with the flow & have fun! Else fight the flow
Go to Top of Page

kapilarya
Yak Posting Veteran

86 Posts

Posted - 2005-08-11 : 08:49:23
hey Sprit,

my main problem is that on the basis of field updated i want to do auditing and not all fields. and when i write

if update(<ntext field>

then trigger doent work

Kapil Arya
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-08-11 : 08:53:03
of course not... no info about ntext columns goes to the trigger.
even it's value must be obtained by joining like i showed you.


Go with the flow & have fun! Else fight the flow
Go to Top of Page

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2005-08-11 : 09:40:03
just out of curiosity, was the ntext datatype necessary for these columns? What is the maximum expected length of these values?

The only reason I ask is because I think its a common misconception that free form text-entry fields need to be defined as text/ntext columns in sql server. If varchar/nvarchar will work for these values, it saves a lot of coding heartache.

Be One with the Optimizer
TG
Go to Top of Page
   

- Advertisement -