I’m doing an INSERT INTO query in order to initialize a new table.
The primary key is RFQ_ID and Action_Time
How could add 1 millisecond to each Action_Time on a new record in order to avoid “Violation of PRIMARY KEY constraint”
INSERT INTO QSW_RFQ_Log
(RFQ_ID, Action_Time, Quote_ID)
SELECT RFQ_ID, GETDATE() AS Action_Time, Quote_ID, 'Added to RFQ on Initialization' AS Note
FROM QSW_Quote
I think the real problem is that
RFQ_ID, Action_Timeshouldn’t be a primary key. Create a surrogate primary key and put a non-unique index onRFQ_ID, Action_Time.Update: If you really want to stick with your existing design you could do what you asked but using 10 milliseconds instead of one millisecond between each row, to compensate for the low precision of datetime. You can use the row number to determine how many milliseconds to add so that you get a different timestamp for each row: