Find all date and time columns in SQL Server database - SQL Server Data Dictionary Queries

PHOTO EMBED

Thu Jan 26 2023 11:10:50 GMT+0000 (Coordinated Universal Time)

Saved by @paulbarry

select schema_name(t.schema_id) + '.' + t.name as [table],
       c.column_id,
       c.name as column_name,
       type_name(user_type_id) as data_type,
       scale as second_scale
from sys.columns c
join sys.tables t
     on t.object_id = c.object_id
where type_name(user_type_id) in ('date', 'datetimeoffset', 
      'datetime2', 'smalldatetime', 'datetime', 'time')
order by [table],
         c.column_id;
content_copyCOPY

https://dataedo.com/kb/query/sql-server/find-all-date-and-time-columns