Timestamp issues about inserting a large number of records at once

Riley 380 Reputation points
2023-03-30T08:46:58.27+00:00

Here is what I am concerned:

If I have a transaction inserts 1 million records using the getdate() function, will there be different timestamp, or will the inserted create_time always be the same?

insert into table1(id,create_time)  select id,getdate() from table2

Thanks in advance!

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
12,852 questions
0 comments No comments
{count} votes

Accepted answer
  1. CosmogHong-MSFT 23,556 Reputation points Microsoft Vendor
    2023-03-30T08:53:41.1766667+00:00

    Hi @Siver

    As far as I know, Getdate() returns the same value in one single statement.

    If you want to ensure the same inserted create_time, it is recommended to assign getdate to a parameter and then use this parameter in the insert statement.

    Best regards,

    Cosmog Hong


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our Documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

0 additional answers

Sort by: Most helpful