How to get updates of changes to the database
Have you ever encountered in developing longer and you do not remember what you did and what updated and created.
No - then you can not continue reading the article.
If so - and also worked with a database ...
So probably you wanted to know what you did (and don't remember)
Here's a query that returns all the tables,views,stored procedures and functions which have changed in the last 30 days (you can change 30 to any number)
The result
No - then you can not continue reading the article.
If so - and also worked with a database ...
So probably you wanted to know what you did (and don't remember)
Here's a query that returns all the tables,views,stored procedures and functions which have changed in the last 30 days (you can change 30 to any number)
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
-- =============================================
-- Author: Roi Kolbinger
-- Create date: 02/08/2008
-- Description: Get tables,views,stored procedures and functions that modified for 30 days
-- =============================================
ALTER PROCEDURE [dbo].[GetAllDBDetails]
AS
BEGIN
-- ======================views=======================
SELECT name AS view_name
,SCHEMA_NAME(schema_id) AS schema_name
,OBJECTPROPERTYEX(object_id,'IsIndexed') AS IsIndexed
,OBJECTPROPERTYEX(object_id,'IsIndexable') AS IsIndexable
,create_date
,modify_date
FROM sys.views
Where modify_date > (getdate()-30)
-- ======================tables=======================
SELECT name AS table_name
,SCHEMA_NAME(schema_id) AS schema_name
,OBJECTPROPERTYEX(object_id,'IsIndexed') AS IsIndexed
,OBJECTPROPERTYEX(object_id,'IsIndexable') AS IsIndexable
,create_date
,modify_date
FROM sys.tables
Where modify_date > (getdate()-30)
-- ======================stored prordures=======================
SELECT name AS procedures_name
,SCHEMA_NAME(schema_id) AS schema_name
,OBJECTPROPERTYEX(object_id,'IsIndexed') AS IsIndexed
,OBJECTPROPERTYEX(object_id,'IsIndexable') AS IsIndexable
,create_date
,modify_date
FROM sys.procedures
Where modify_date > (getdate()-30)
-- ======================functions=======================
SELECT name AS function_name
,SCHEMA_NAME(schema_id) AS schema_name
,type_desc
,create_date
,modify_date
FROM sys.objects
WHERE type_desc LIKE '%FUNCTION%'
and modify_date > (getdate()-30)
END
The result
To see more examples - use this line : http://msdn.microsoft.com/en-us/library/ms345522.aspx
Yours,
Roi
Comments
Post a Comment