SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Which Stored Procedure changed


Which Stored Procedure changed

Author
Message
ramadesai108
ramadesai108
SSCertifiable
SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)

Group: General Forum Members
Points: 5205 Visits: 690
Hi all,
Are there any system stored procedures or anyway to know which user stored procedures changed in the past month? Your help is alway appreciated. I find this forum very helpful and life saving, not to mention time saving.
John Mitchell-245523
John Mitchell-245523
SSC Guru
SSC Guru (68K reputation)SSC Guru (68K reputation)SSC Guru (68K reputation)SSC Guru (68K reputation)SSC Guru (68K reputation)SSC Guru (68K reputation)SSC Guru (68K reputation)SSC Guru (68K reputation)

Group: General Forum Members
Points: 68413 Visits: 17522
Yes, something like this:

SELECT SPECIFIC_SCHEMA + '.' + SPECIFIC_NAME AS ProcName, LAST_ALTERED
FROM INFORMATION_SCHEMA.ROUTINES
WHERE ROUTINE_TYPE = 'PROCEDURE'
AND LAST_ALTERED > GETDATE() - 7



John
Andras Belokosztolszki
Andras Belokosztolszki
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10611 Visits: 1585
John's solution is nice, because it is using the INFORMATION_SCHEMA views (part of the SQL Standard Smile, and is portable). But if you prefer SQL Server 2005 (and 2008) system views, you can write the above like:

SELECT schema_name(schema_id) + '.' + name AS ProcName
, modify_date
FROM sys.procedures
WHERE modify_date > GETDATE() - 7



Regards,
Andras



Andras Belokosztolszki, MCPD, PhD
GoldenGate Software
ramadesai108
ramadesai108
SSCertifiable
SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)

Group: General Forum Members
Points: 5205 Visits: 690
Thank you John and Andras. When I run the query it shows only newly created Procedures and not altered procedures that were already existing, even when the cirteria includes "LAST_ALTERED".
Adam Haines
Adam Haines
SSChampion
SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)

Group: General Forum Members
Points: 11646 Visits: 3135
Are the stored procedures being dropped/created and not altered. I think this would render the previous solution invalid.



My blog: http://jahaines.blogspot.com
Adam Haines
Adam Haines
SSChampion
SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)

Group: General Forum Members
Points: 11646 Visits: 3135
Ideally, you need to implement some sort of object tracking system. A few available options are source control and DDL triggers.

Source control allows you answer the big questions like, what changed, who changed it, and when was it changed. SSMS allows a snap in to some of the bigger source control systems. Go to the menu item Tool --> options --> source control.

DDL triggers give you the ability to track infomation about who drops/alter/creates objects, such as stored procedures. The great thing about this is you can even rollback the transaction and send a message saying dropping stored procedures is not allow.



My blog: http://jahaines.blogspot.com
ckuroda
ckuroda
SSC-Enthusiastic
SSC-Enthusiastic (134 reputation)SSC-Enthusiastic (134 reputation)SSC-Enthusiastic (134 reputation)SSC-Enthusiastic (134 reputation)SSC-Enthusiastic (134 reputation)SSC-Enthusiastic (134 reputation)SSC-Enthusiastic (134 reputation)SSC-Enthusiastic (134 reputation)

Group: General Forum Members
Points: 134 Visits: 96
I'm not sure which server version you are using, but in SQL Server 2008 ( including Express ) you can sort the procedures in descending modified date in the Object explorer details view.

Open the stored procedures folder in the Object Explorer Details.
If the Modified Date is not displayed, right click on the 'Name' heading to view the shortcut menu. Check the 'Date Last Modified' option to display it.
Click on the field headings to sort the list of stored procedures.

Cheers
Chieko



Dream Weaver
Dream Weaver
SSC-Addicted
SSC-Addicted (486 reputation)SSC-Addicted (486 reputation)SSC-Addicted (486 reputation)SSC-Addicted (486 reputation)SSC-Addicted (486 reputation)SSC-Addicted (486 reputation)SSC-Addicted (486 reputation)SSC-Addicted (486 reputation)

Group: General Forum Members
Points: 486 Visits: 315
Regarding the statement that you could see changes in the dates when you used CREATE, but not when you use ALTER, with the queries provided in this tread...

What version of SQL Server are you using? I don't have a place to confirm anymore, but I seem to remember that in SQL 2000 (and maybe 2005), the DateModified value didn't get changed in the system tables when a stored procedure was ALTERed.

Of course, my memory could be way off, too. But it may be worth a quick test.



ramadesai108
ramadesai108
SSCertifiable
SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)

Group: General Forum Members
Points: 5205 Visits: 690
This post was created in March of 2009 and now all of a sudden i am seeing responses. I could not follow ckuroda's instruction on how to see the dates on altered SPs. I am using version 2005.
Lowell
Lowell
SSC Guru
SSC Guru (155K reputation)SSC Guru (155K reputation)SSC Guru (155K reputation)SSC Guru (155K reputation)SSC Guru (155K reputation)SSC Guru (155K reputation)SSC Guru (155K reputation)SSC Guru (155K reputation)

Group: General Forum Members
Points: 155607 Visits: 41543
I'm surprised noone mentioned the Default Trace yet, that contains all the recent DDL Changes;
there's a built in report from the default trace in SSMS: shows table drops and created, proc and function drops/alters/creates and more:


Lowell
--help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum







































































































































































SQLServerCentral


Search