Tuesday, September 22, 2015

How to get schema change history

SELECT s.name AS schema_name, o.name AS OBJECT_NAME, o.type_desc, o.create_date, o.modify_date
FROM   sys.all_objects o
LEFT OUTER JOIN sys.schemas s ON ( o.schema_id = s.schema_id)
WHERE create_date > ( GETDATE() - 7) 
AND o.name = 'st_school_admin_data_select'
ORDER BY o.name 


you can use in this way

DECLARE @dt AS DATETIME = GETDATE()
SELECT FORMAT(@dt, 'hh:mm tt')

DECLARE @t AS DATETIME = GETDATE()
SELECT FORMAT(CAST(@t AS DATETIME), 'hh:mm tt')