SQL Server表创建日期查询


91

如何使用SQL查询获得MS SQL表的表创建日期?
我在物理上看不到任何表,但可以查询该特定表。

Answers:


140

2005年起,您可以使用

SELECT
        [name]
       ,create_date
       ,modify_date
FROM
        sys.tables

我认为对于2000年,您需要启用审核。


30

对于SQL Server 2005以上版本:

SELECT [name] AS [TableName], [create_date] AS [CreatedDate] FROM sys.tables

对于SQL Server 2000以上版本:

SELECT so.[name] AS [TableName], so.[crdate] AS [CreatedDate]
FROM INFORMATION_SCHEMA.TABLES AS it, sysobjects AS so 
WHERE it.[TABLE_NAME] = so.[name]


6

如果您还需要架构:

SELECT CONCAT(ic.TABLE_SCHEMA, '.', st.name) as TableName
   ,st.create_date
   ,st.modify_date

FROM sys.tables st

JOIN INFORMATION_SCHEMA.COLUMNS ic ON ic.TABLE_NAME = st.name

GROUP BY ic.TABLE_SCHEMA, st.name, st.create_date, st.modify_date

ORDER BY st.create_date

5

对于SQL Server 2000:

SELECT   su.name,so.name,so.crdate,* 
FROM     sysobjects so JOIN sysusers su
ON       so.uid = su.uid
WHERE    xtype='U'
ORDER BY so.name
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.