2021年3月10日星期三

Perform insert in SQL Server with timestamp that increments

I have a script inserting a few hundred thousand records into a table. One of the columns is a DATETIME2(7), and I'm inserting SYSUTCDATETIME() into it. The problem is that every single record has the same exact time stamp. I'm trying to avoid doing a cursor or while loop, and just perform a nice fast insert into/select from kind of statement.

Is there a way to have the time increment, even it it's by nano seconds, in a straight insert? e.g.

INSERT INTO [dbo].[Users]       ( [FirstName]       , [LastName]       , [CreatedDate] )  SELECT  [DI].[FirstName] AS [FirstName]        , [DI].[LastName]  AS [LastName]        , SYSUTCDATETIME() AS [CreatedDate]  FROM    [dbo].[DataImport] AS [DI];  
https://stackoverflow.com/questions/66575082/perform-insert-in-sql-server-with-timestamp-that-increments March 11, 2021 at 09:05AM

没有评论:

发表评论