开发者

Access DateTime of row written to table if no DateTime field in table - SQL Server 2008

I have a situation where I need to find out the most recent entry written to a table but the person who developed the database created the table without a DateTime field or an auto-incr开发者_开发问答ementing ID field.

I am wondering is there any way of accessing some built in DateTime proprty recorded by SQL Server or any other way of determining the more recent entry out of say two results like this:

idp_fund_id    IDPID
14             1653
18             1653

Below is the structure

CREATE TABLE [dbo].[web_IDP_Lifestyle](
 [idp_fund_id] [int] NOT NULL,
 [IDPID] [int] NOT NULL,
 CONSTRAINT [PK_web_IDP_Lifestyle] PRIMARY KEY CLUSTERED 
(
 [idp_fund_id] ASC,
 [IDPID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]


In short: no.

You might be able to compare for existence of those values in backups... depending on how far the backups go.

I'm assuming that the idp_fund_id of 18 might have been written before the value of 14?


Nope.

SQL Server doesn't keep detailed records on this. If it DID, think about how large the metadata would have to be in order to track the update/insert time for each and every record in each and every table.

SQL doesn't order inserts by default, and I don't think you can check what page it was inserted on to determine this with any reliability, either.

If you want to track something like this, you need to create a field/table for it to track it yourself and implement some triggers.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜