instead of trigger on a view

  • i have created a instead of trigger on a view .

    My requirement is the i need to send only the difference records to the table , but a view gets refreshed for everyupdate,so it is reflecting all the records along with the new inserts in the table .

    I want to compare the timestamps , like the time the record was inserted to the the time it was refreshed , so can any one help me write a t-sql to this .

  • definition of the view?

    the more info you give us, the more we can help.

    what did you try so far? does the base table have a column with an updatedtime in it?

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • looktable does have a primary key which is a genearated key and the lookup_id and the description and the date_modified , which i am getting through get_date() , function.

    i am trying to insert values into this lookup table through a view which i am getting it through the EDW .

    so the query which i used is

    set ANSI_NULLS ON

    set QUOTED_IDENTIFIER ON

    go

    create TRIGGER [view_test_trial_trigger]

    ON [dbo].[view_test]

    INSTEAD OF INSERT

    AS

    BEGIN

    --Build an INSERT statement ignoring inserted.PrimaryKey and

    --inserted.ComputedCol.

    INSERT INTO view_test_lk

    SELECT CONG_DISTRICT , 'CONGRESS DISTRICT'CONG_DISTRICT ,getdate()

    FROM inserted

    where current_timestamp = inserted.getdate()

    end

    END

    but it is not even getting fired even if the EDW folks insert a value into the view .

    so the trigger is not working also .

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply