SQL Server Table Creation Date Query

SQL Server table creation date query

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.

Get the list of tables created on any date?

SELECT *
FROM sys.tables
WHERE create_date >= '20120914' AND create_date < '20120915'

Find the date/time a table's column was created

There's this system table named sys.Columns that you can get columns information from it.
if you want to see columns of a particular table you can do as follows:

SELECT col.* from sys.objects obj 
inner join sys.columns col
on obj.object_Id=col.object_Id
and obj.Name=@tableName

Or you can get table information like this:

SELECT * FROM sys.objects WHERE Name=@tableName

but I couldn't find any information on creation date of a column.

Updated:
This might help.

SQL Statement That Will Get Table Schema And Created Date

The create_date field is stored in sys.tables. You can then join back to sys.schemas to get the schema name.

Something like this:

declare @SqlStatement varchar(max)
select @SqlStatement = COALESCE(@SqlStatement, '') + 'DROP TABLE [TMP].' + QUOTENAME(t.name) + ';' + CHAR(13)
from sys.tables t
join sys.schemas s on t.schema_id = s.schema_id
where s.name = 'TMP'
and t.create_date > dateadd(day,-1,getdate())
print @SqlStatement

Creation date column in SQL table

ALTER TABLE table
ADD column NOT NULL DEFAULT (GETDATE())

Getting the creation date of an entry in SQL Server table

AFAIK- No, unless you have a field for that and you are setting it when doing INSERT/UPDATE



Related Topics



Leave a reply



Submit