创建列的日期和时间 [英] Date and Time when a column was created

查看:90
本文介绍了创建列的日期和时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道何时为特定表创建列...



例如

Table1有2列像EMPID,EMPNAME



几天后,我又在'Table1'中添加了2个列作为'Location'和'ActiveYn'



现在我想知道何时将所有这些特定列添加到表中

I want to know when a column was created for a particular table..

For example
Table1 is having 2 columns like EMPID,EMPNAME

After few days now i am adding 2 more columns to the 'Table1' as 'Location' and 'ActiveYn'

Now i want to know when all these particular columns are added to the table

推荐答案





看看这里:

http://stackoverflow.com/a/1425577 [ ^ ]


在我看来,不可能获得特定列的创建日期,但是可以获得表的修改日期。





感谢RedDK提供评论和有用的信息;)

[/ EDIT]



只需测试它(根据您的需要改变):

In my opinion it's not possible to get creation date for particular column, but it's possible to get modified date for table.


Thanks RedDK for comment and useful information ;)
[/EDIT]


Just test it (change to your needs):
USE LIDL;
GO

DECLARE @tableName VARCHAR(50)
DECLARE @columnName VARCHAR(50)

SET @columnName = 'AAA'
SET @tableName = 'Import'

--show create date and modify date before altering table
SELECT obj.create_date, modify_date
from sys.objects obj
inner join sys.columns col on obj.object_Id=col.object_Id
WHERE col.name = @columnName and obj.Name=@tableName

--insert new column
ALTER TABLE Import ADD COLUMN AAA INT NULL
GO

--view create_date and modify_date after altering table
SELECT obj.create_date, modify_date
from sys.objects obj
inner join sys.columns col on obj.object_Id=col.object_Id
WHERE col.name = @columnName and obj.Name=@tableName





请参阅:sys.objects(Transact-SQL) [ ^ ]


这篇关于创建列的日期和时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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