TRigger problem/Limitation

Last post 08-18-2008, 2:53 AM by MVV. 1 replies.
Sort Posts: Previous Next
  •  08-11-2008, 5:35 AM Post number 67715

    • baddy is not online. Last active: 10-30-2008, 5:49 AM baddy
    • Top 25 Contributor
    • Joined on 04-07-2008
    • India
    • Blue Gene

    TRigger problem/Limitation

    Hi Experts –

    I want to insert/update/delete records into some other table a (say history table). & for this I'm using triggers

    Firstly I tried instead of TRIGGER for insert, delete & update statements, as instead of triggers doesn’t support for the table having FOREIGN KEY with cascading DELETE or UPDATE

    So i created After Trigger to captures these insert/update/delete statements, in after triggers, SQL Server does not allow text, ntext, or image column references in the inserted and deleted tables. As we are capturing the events (insert/update/delete) data from these two logical tables inserted and deleted.

    As my table have BLOB (image, text, text) variables. I can't change the DB schema. I have to do something using Triggers…

    But In both cases there is limitation i.e.

    INSTEAD OF TRIGGER – doesn’t support table having cascading.

    AFTER TRIGGER – doesn’t allow text, ntext, image column references in the inserted and deleted.

     

    Any Suggestion Please…!

     

    Thanks in advance,

    baddy

     


    Thanks,
    Baddy
  •  08-18-2008, 2:53 AM Post number 69042 in reply to post number 67715

    • MVV is not online. Last active: 12-01-2008, 6:48 AM MVV
    • Top 25 Contributor
    • Joined on 04-29-2008
    • Alcoy, Spain
    • Level 2: Deep Blue

    Re: TRigger problem/Limitation

    How are the records inserted / deleted in the tables?
    The logical place to do this would be in a Stored Procedure , where all the interaction between the program and the database should take place. It's easier and cleaner to do it this way.

    If there are insertions out of your control , done by program code , and you can't touch the db schema, i'm not sure you can do it by triggers. If that blob fields are not used anymore , and you can at least change the table name  , you could try with a schemabinded view and a instead of trigger there. The user sees a "virtual" table and you can control what enters and how it goes. Just an idea , not sure if this will help you.


    Hey , sysadm , leave the users alone
    They are nothing more
    than another brick in the firewall
View as RSS news feed in XML