Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Server table creation date query

People also ask

How can I tell when a SQL Server table was created?

In the Object Explorer in SQL Server Management Studio, go to the database and expand it. Under the Tables folder select the table name. Right click and select Properties from the menu. You will see the created date of the table in the General section under Description.

What does date () do in SQL?

The date function DAY accepts a date, datetime, or valid date string and returns the Day part as an integer value.


For 2005 up, you can use

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

I think for 2000, you need to have enabled auditing.


For SQL Server 2005 upwards:

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

For SQL Server 2000 upwards:

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

SELECT create_date
FROM sys.tables
WHERE name='YourTableName'

In case you also want Schema:

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

For 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