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 the TIMESTAMP
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.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…