Hello,
I've a requirement where I want to insert/update into a table based on a primary key.
I've one column named RECORD_DATE whose default value I've set to current_timestamp.
Now when I'm getting a new record on the same primary key, I don't want to update the record_date column with current_timestamp.
In current scenario, my record_date column also gets updated to current_timestamp.
Is there a way on how can I achieve this?
CREATE COLUMN TABLE PH_UPSERT_CHECK( ID INT, NAME NVARCHAR(10), RECORD_DATE SECONDDATE DEFAULT CURRENT_TIMESTAMP, CONSTRAINT CPK_UP PRIMARY KEY(ID)); UPSERT PH_UPSERT_CHECK(ID,NAME)VALUES(1,'PH') WITH PRIMARY KEY;
1. When I run this record on an empty table, record_date should get updated(as it is insert)
2. When I re-run this record on the table for the next time with some change in column NAME (update)
the record_date column shouldn't be updated.
Florian Pfeffer can you help me with the same?
TIA.
Regards,
Prathamesh H.