datetime row created I have sqlserver DB , and there I have few tables.

I have 1 table that not save each row what is the datetime the each row created.


Is there any way to know when which row was created?
Is there any way (without changing the application that created the row
on this db, I can't add any SP to do it) that from now, when the
row is created, it will automatically add the created dateTime?
For the first question, you can't get data that isn't stored in your system. There is no way to know the date from which each row was inserted or updated if you don't have it stored somewhere.

For the second question, you can create a new column with a default constraint that will automatically set the current datetime value (if it wasn't supplied by the client), or an AFTER INSERT trigger that updates this column also. On both cases you need a column to store this value.

ALTER TABLE SchemaName.YourTable ADD CreatedDate DATETIME



Using a constraint with default value:

ALTER TABLE SchemaName.YourTable ADD CONSTRAINT DF_SchemaNameYourTable_CreatedDate 
DEFAULT GETDATE() FOR CreatedDate

Using a trigger:

CREATE TRIGGER SchemaName.utrYourTableUpdateCreatedDate ON SchemaName.YourTable
    AFTER INSERT
AS
BEGIN

    UPDATE T SET
        CreatedDate = GETDATE()
    FROM
        inserted AS I -- special table that holds only new inserted rows (in this case)
        INNER JOIN SchemaName.YourTable AS T ON I.KeyColumn = T.KeyColumn

END