Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 proc changes track

Author  Topic 

pnpsql
Posting Yak Master

246 Posts

Posted - 2012-06-03 : 00:22:31
i need to get all chnage information for a proc .

how can i write a query . to get if a proc change in last 30 days i use following but a also need the changes.




SELECT name, create_date, modify_date
FROM sys.objects
WHERE type = 'P'
and name like '%pr_test_block%'
AND DATEDIFF(D,modify_date, GETDATE()) < 30



challenge everything

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-06-03 : 00:45:22
what do you mean need changes? do you mean changes you did in actual proc? Do you've a version control software like SVN/VSS?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

vijays3
Constraint Violating Yak Guru

354 Posts

Posted - 2012-06-03 : 04:09:24



By doing this you can track the proc changes:




create table
dbo.AdministratorLog(databasename varchar(256)
, eventtype varchar(50),objectname varchar(256)
, objecttype varchar(25), sqlcommand varchar(max), loginname varchar(256),Modifieddate datetime)




alter TRIGGER [Admin_Backup_Objects]

ON DATABASE

FOR create_procedure, alter_procedure, drop_procedure,

create_table, alter_table, drop_table,

create_function, alter_function, drop_function

AS



SET NOCOUNT ON



DECLARE @data XML

SET @data = EVENTDATA()


--drop table AdministratorLog
INSERT INTO dbo.AdministratorLog(databasename, eventtype,objectname, objecttype, sqlcommand, loginname,Modifieddate)

VALUES(

@data.value('(/EVENT_INSTANCE/DatabaseName)[1]', 'varchar(256)'),

@data.value('(/EVENT_INSTANCE/EventType)[1]', 'varchar(50)'), -- value is case-sensitive

@data.value('(/EVENT_INSTANCE/ObjectName)[1]', 'varchar(256)'),

@data.value('(/EVENT_INSTANCE/ObjectType)[1]', 'varchar(25)'),

@data.value('(/EVENT_INSTANCE/TSQLCommand)[1]', 'varchar(max)'),

@data.value('(/EVENT_INSTANCE/LoginName)[1]', 'varchar(256)'),
getdate()

)


alter procedure pro
as
begin

select getdate()
end


select * from dbo.AdministratorLog


Vijay is here to learn something from you guys.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-06-03 : 15:26:50
You also have a standard report which gives details of objects changes

see

http://www.dotnetfunda.com/articles/article22.aspx

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -