This trigger will act like version control on your database, After each release you have to set a Release Label, before release you can query by Release Label and date descending to populate all the changes done
/****** Object: Table [dbo].[dbChangeLog] Script Date: 06/16/2010 17:32:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[dbChangeLog](
[AutoID] [numeric](18, 0) IDENTITY(1,1) NOT NULL,
[CreatedDate] [datetime] NULL,
[EventType] [varchar](90) NULL,
[LoginName] [varchar](50) NULL,
[UserName] [varchar](50) NULL,
[DatabaseName] [varchar](50) NULL,
[SchemaName] [varchar](80) NULL,
[ObjectName] [varchar](90) NULL,
[ObjectType] [varchar](90) NULL,
[TSQLCommand] [nvarchar](max) NULL,
[DbVersion] [varchar](50) NULL,
[MostRecent] bit NULL
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
and the Trigger should be something like this
/****** Object: DdlTrigger [DDL_on_Table_and_PROC] Script Date: 06/16/2010 17:34:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TRIGGER [DDL_on_Table_and_PROC]
ON DATABASE
FOR CREATE_TABLE,DROP_TABLE,
ALTER_TABLE,CREATE_PROCEDURE,
ALTER_PROCEDURE,DROP_PROCEDURE
AS
BEGIN
declare @CreatedDate datetime
declare @EventType varchar(50)
declare @LoginName varchar(50)
declare @UserName varchar(50)
declare @DatabaseName varchar(50)
declare @SchemaName varchar(150)
declare @ObjectName varchar(150)
declare @ObjectType varchar(50)
declare @CommandText nvarchar(max);
set @EventType=(SELECT EVENTDATA().value
('(/EVENT_INSTANCE/EventType)[1]',
'varchar(50)'));
set @LoginName=(SELECT EVENTDATA().value
('(/EVENT_INSTANCE/LoginName)[1]',
'varchar(100)'));
set @UserName=(SELECT EVENTDATA().value
('(/EVENT_INSTANCE/UserName)[1]',
'varchar(100)'));
set @DatabaseName=(SELECT EVENTDATA().value
('(/EVENT_INSTANCE/DatabaseName)[1]',
'nvarchar(150)'));
set @SchemaName=(SELECT EVENTDATA().value
('(/EVENT_INSTANCE/SchemaName)[1]',
'varchar(150)'));
set @ObjectName=(SELECT EVENTDATA().value
('(/EVENT_INSTANCE/ObjectName)[1]',
'varchar(100)'));
set @ObjectType=(SELECT EVENTDATA().value
('(/EVENT_INSTANCE/ObjectType)[1]',
'varchar(50)'));
set @CommandText=(SELECT EVENTDATA().value
('(/EVENT_INSTANCE/TSQLCommand/CommandText)[1]',
'nvarchar(max)'));
--set @statusReport=(SELECT convert(varchar(500),EVENTDATA()));
--
--
--select @CommandText 'TSQL Coomand'
--select @objectType 'Table/Stored Proc'
--select @databaseName 'database Name'
----select @EventType '@EventType Name'
--select @ObjectName '@Object Name'
----------------------------------------------------------------------------------------------------
-- This will update all the old entry so that before release you can get all the updates procedure and table
------------------------------------------------------------------------------------------------------
UPDATE dbChangeLog
SET MostRecent = 0
WHERE ObjectType = @ObjectType
AND ObjectName = @ObjectName
AND DbVersion = 'Rel-D'
----------------------------------------------------------------------------------------------------
-- This will Insert a new Row in Log Table
------------------------------------------------------------------------------------------------------
INSERT INTO [dbChangeLog]
([CreatedDate],[EventType]
,[LoginName]
,[UserName]
,[DatabaseName]
,[SchemaName]
,[ObjectName]
,[ObjectType]
,[TSQLCommand]
,[DbVersion]
,[MostRecent])
VALUES
(GETDATE(),@EventType
,@LoginName
,@UserName
,@DatabaseName
,@SchemaName
,@ObjectName
,@ObjectType
,@CommandText
,'Rel-D'
,1)
END
GO
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER OFF
GO
DISABLE TRIGGER [DDL_on_Table_and_PROC] ON DATABASE
GO
ENABLE TRIGGER [DDL_on_Table_and_PROC] ON DATABASE
GO
I hope you don’t need the select command which will populate the most updated changed on database. In case you can’t make the query let me know.