• Lynn Pettis (11/30/2015)


    Alvin Ramard (11/30/2015)


    Lynn Pettis (11/30/2015)


    Pulling hen's teeth, but based on what little detail you have been willing to provide, does the following help?

    create table dbo.FirstTable(

    ColA int,

    ColB int,

    ColC datetime null);

    create table dbo.SecondTable(

    ColA int,

    ColB int,

    ColC datetime null);

    go

    create trigger dbo.DataMove on dbo.FirstTable for insert, update

    as

    insert into dbo.SecondTable(ColA,ColB,Colc)

    select ins.ColA, ins.ColB, ins.ColC

    from inserted ins

    where ins.ColC > '' or ins.ColC <> (select del.ColC from deleted del where del.ColA = ins.ColA);

    go

    insert into dbo.FirstTable(ColA,ColB,ColC)

    values

    (446063,6543,NULL),

    (443107,6543,NULL),

    (3034 ,1152,NULL),

    (443451,6543,NULL),

    (440501,6543,NULL),

    (9973 ,515 ,'2005-10-04 14:34:00.673'),

    (10650 ,515 ,'2005-10-04 14:34:19.953'),

    (10651 ,515 ,'2005-10-04 14:35:09.343'),

    (15289 ,511 ,'2005-10-25 11:30:31.227'),

    (15334 ,511 ,'2005-10-25 11:30:50.600');

    select * from dbo.FirstTable;

    select * from dbo.SecondTable;

    update dbo.FirstTable set

    ColC = getdate()

    where ColA = 3034;

    select * from dbo.FirstTable;

    select * from dbo.SecondTable;

    I am sure there is more involved, but you really haven't been forth coming with any details.

    I think we need an additional condition in the where clause:

    and ins.ColC IS NOT NULL

    Why? If ins.ColC > '' it isn't NULL.

    I could seeing changing it to ins.ColC is not null.

    Is ins.Colc > '' when ins.ColC is null? If so, then you would be correct. I just don't like comparing nulls to anything.

    Another option would be:

    ISNULL(ins.ColC, '') > ''



    Alvin Ramard
    Memphis PASS Chapter[/url]

    All my SSC forum answers come with a money back guarantee. If you didn't like the answer then I'll gladly refund what you paid for it.

    For best practices on asking questions, please read the following article: Forum Etiquette: How to post data/code on a forum to get the best help[/url]