获取表格列的创建日期

时间:2011-10-28 16:51:45

标签: sql-server

我找到了一个获取列信息的脚本:

SELECT 
   crdate as thisFieldIsNotTheCreationOfTheField1 ,
   refdate as thisFieldIsNotTheCreationOfTheField2 ,
   o.name AS [TableName],
   o.type,
   c.name AS [ColName],
   s.name AS [ColType],
   c.prec,
   c.scale,
   c.isnullable
FROM       
   dbo.sysobjects AS o
INNER JOIN
   dbo.syscolumns AS c ON c.id = o.id
INNER JOIN
   dbo.systypes AS s ON c.xtype = s.xtype
WHERE  
   o.type = 'U' and o.name='TableNa'
ORDER BY
   crdate

找不到列创建日期时间。

如何做到这一点?

1 个答案:

答案 0 :(得分:3)

这就是你想要的:

SELECT obj.create_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