Bienvenidos

Recuerda que tus comentarios son importantes y recuerda agradecer si te fue útil algun artículo publicado aquí.

L1f3 15 a D@nc3 Flo0r

jueves, 14 de febrero de 2019

Query para ver los objetos modificados en la base de datos

Para ver los objetos creados y/o modificados en una base de datos de SQL Server podemos utilizar el siguiente query:

declare @ano int
set @ano = 2019 
declare @mes int
set @mes = 01
select name, [type], [type_desc], create_date, modify_date
from sys.objects
where type not in ('SQ','D','F','IT','PK','S')
  and (year(modify_date) = @ano or year(create_date) = @ano)
  and (create_date <> modify_date or create_date = modify_date)
ORDER BY modify_date, [TYPE], [NAME]

En este caso estamos filtrando  por año y mes y estamos excluyendo algunos objetos.

Listado de objetos disponibles:

D :  DEFAULT_CONSTRAINT
F :  FOREIGN_KEY_CONSTRAINT
FN :  SQL_SCALAR_FUNCTION
IT :  INTERNAL_TABLE
P :  SQL_STORED_PROCEDURE
PK :  PRIMARY_KEY_CONSTRAINT
S :  SYSTEM_TABLE
SQ :  SERVICE_QUEUE
U :  USER_TABLE
V :  VIEW

No hay comentarios: