I have a table with a TIMESTAMP
column:
create table dbo.EX_EMPLOYEE (
NAME_X varchar(10) null,
RECORD_TIME_STAMP timestamp null
)
when I copy the rows from one table to another, using either:
SELECT * INTO EX_EMPLOYEE_T
FROM EX_EMPLOYEE
WHERE 1=0
or:
INSERT INTO EX_EMPLOYEE_T
SELECT *
FROM EX_EMPLOYEE
I get this warning:
Warning: A non-null value cannot be inserted into a
TIMESTAMP
column by the user. The database timestamp value has been inserted into theTIMESTAMP
field instead.
The TIMESTAMP
column in the target table is replaced with the current database timestamp.
My question
How to copy rows with a TIMESTAMP
column, while preserving the TIMESTAMP
value from the source table ?
(Is there a setting similar to SET IDENTITY ON/OFF
)
My scenario
I have 2 tables, one for "live" data and the other for "backup", so I need to copy the rows with the TIMESTAMP
intact. I need it intact in order to detect if there has been a change to the "live" row.
The Sybase (now SAP) replication server (SRS) can replicate timestamp values between Sybase/SAP ASE tables, ie, the SRS maintuser can insert explicit values into a column of type
timestamp
.How is this possible? There are a few requirements:
timestamp
column) must have thereplication_role
role (and it has to be active)set timestamp_insert on
command (NOTE: this will generate an error if your user doesn't havereplication_role
)Setup:
Now for some insert tests ...
Above was tested on a ASE 15.7 SP138 dataserver.