如何找到插入行的日期? [英] How to find the date when the row was inserted?

查看:90
本文介绍了如何找到插入行的日期?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要知道将行插入sql server中的表的日期.我想知道从有关日期开始更新值的日期.

I need to know the date when the row was inserted into a table in sql server. I want to know the date for updating the values from the concerned date.

推荐答案

如果启用了正确的日志记录,则可能会在其中找到它,但是SQL找不到存储每一行​​的插入日期.

如果需要,则需要包含日期 [创建默认值 [
If you have the proper logging enabled you might find it in there, but SQL does not store an insertion date for each row.

If you need this than you need to include the date[^] into your table design.
You can use CREATE DEFAULT[^] so that newly added rows get the current date automatically.


用于存储插入详细信息的日期时间
创建列说它InsertionDate
现在,将其设置为默认值= GetDate()

对于更新日期时间
创建列说它UpdateDate
1.现在,在更新查询时设置其值
示例:更新tbl设置updateDate = getdate(),col1 = 1,col2 =''hello''其中...
2.或设置列的数据类型=时间戳列

祝您编码愉快!
:)
for storing insertion detail''s datetime
create column say it InsertionDate
now, set it''s default value = GetDate()

for update datetime
create column say it UpdateDate
1. now, set it''s value when updating query
example: update tbl set updateDate=getdate(),col1=1,col2=''hello'' where ...
2. or set column''s datatype = timestamp column

Happy Coding!
:)


感谢您的帮助.

但是我的桌子上已经有几千行了.我只想知道行插入日期,只需将英文日期添加到每一行的新列中即可.

我通过将尼泊尔语日期(已在表格中)转换为英语日期到此新列来解决了这个问题.

再次谢谢大家.
Thank you for your help.

But i had some thousand rows already in my table. I just wanted to know the row insertion date to simply add english date to a new column for each row.

I solved it by converting nepali date (which was already in the table) to english date to this new column.

Thank you all again.


这篇关于如何找到插入行的日期?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆