SQL Server - Problem in trigger - Asked By Bikash Samal on 09-Oct-11 04:23 AM

In my database there is a table, in which data inserted through .exe file.
Problem is that,  the exe file is sending system data, not the server data....
So, I'm getting problem while watching current date data...
I can't change exe file...
So, I execute a trigger so that it'll change the date of the new row inserted to getdate()..
But it changes all the row of the users data from till date as there is no primary key on that table and I can't change database too.....
Hence, I'm asking:
Is there any process to change the date and time of that table to getdate() while new row inserting without giving a primary key to the table???

My trigger code is :
ALTER TRIGGER [change_dtentrytime]
   ON [dbo].[dailytransaction]
   AFTER INSERT 
           
  as
begin
update dailytransaction set dtentry=getdate() where intnoteid=(select intnoteid from inserted)
end

Anybody plz give some solution for this???

Thanks in advance.....
Web Star replied to Bikash Samal on 09-Oct-11 04:42 AM
if column intnoteid in your table is unique than it should works for that if this is not unique then you need to specify uniqueness of particular row by using multiple column as composite key than you will be able to update current date at the time of insertion , basically when you want to update one row which is inserted than you should able to select that row by you query so you put all condition in where clause that will get only new inserted row than your trigger will be work perectly