when when insert row in a table

Devendra Kumar Sahu 246 Reputation points
2023-02-14T11:13:36.6766667+00:00

when a row was inserted into a table on SQL Server?
is it not Nassery date column available of each table

I have 400+ table in a database and

SQL Server Other
0 comments No comments
{count} votes

Accepted answer
  1. Olaf Helper 47,436 Reputation points
    2023-02-14T11:33:53.32+00:00

    If your table don't have a column for the INSERT timestamp, then you can not get the information.

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Anonymous
    2023-02-15T01:56:25.35+00:00

    Hi @Devendra Kumar Sahu

    If you want to get the insert time, you have to make some changes to the table.

    The first is to use timestamps, which need to be implemented by adding a new column to the table.

    https://www.geeksforgeeks.org/capturing-insert-timestamp-in-table-sql-server/

    The second is a new column, which defaults to System Time.

    For example:

    create table test(a int,b int,inserttime datetime default getdate());
    insert into test(a,b) values(1,4),(25,5);
    select * from test;
    

    User's image

    The third method can use triggers. Create a trigger on the table, but the insert time is not displayed in the original table, but in a new table.

    https://www.mssqltips.com/sqlservertip/7429/sql-triggers-for-inserts-updates-and-deletes-on-a-table/

    If you cannot add columns or create triggers to the original table, you cannot obtain the time information.

    Best regards,

    Percy Tang


    If the answer is the right solution, please click "Accept Answer". 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

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.