views:

1602

answers:

7

I Need to manually migrate modified stored procedures from a DEV SQL Server 2005 database instance to a TEST instance. Except for the changes I'm migrating, the databases have the same schemas. How can I quickly identify which stored procedures have been modified in the DEV database for migration to the TEST instance?

I assume I can write a query against some of the system tables to view database objects of type stored procedure, sorting by some sort of last modified or compiled data, but I'm not sure. Maybe there is some sort of free utility someone can point me to.

Thanks in advance,

Bob

+2  A: 

Although not free I have had good experience using Red-Gates SQL Compare tool. It worked for me in the past. They have a free trial available which may be good enough to solve your current issue.

Craig
A: 

You can use following type of query to find modified stored procedures , you can use any number then 7 as per your needs

SELECT name FROM sys.objects WHERE type = 'P' AND DATEDIFF(D,modify_date, GETDATE()) < 7

RBS
+5  A: 

You can execute this query to find all stored procedures modified in the last x number of days:

SELECT name
FROM sys.objects
WHERE type = 'P'
    AND DATEDIFF(D,modify_date, GETDATE()) < X
Jason Stevenson
+1  A: 

you can also use the following code snipet

USE AdventureWorks2008;

GO

SELECT SprocName=name, create_date, modify_date

FROM sys.objects

WHERE type = 'P' 

AND name = 'uspUpdateEmployeeHireInfo'

GO
RBS
A: 

There are several database compare tools out there. One that I've always like is SQLCompare by Red Gate.

You can also try using:

SELECT name
FROM sys.objects
WHERE modify_date > @cutoffdate

In SQL 2000 that wouldn't have always worked, because using ALTER didn't update the date correctly, but in 2005 I believe that problem is fixed.

I use a SQL compare tool myself though, so I can't vouch for that method 100%

Tom H.
+9  A: 

instead of using sysobjects which is not recommended anymore use sys.procedures

select name,create_date,modify_date
from sys.procedures
order by modify_date desc

you can do the where clause yourself but this will list it in order of modification date descending

SQLMenace
Add a top 100 to that to make it even better.
Mike Brown
A: 

Msg 207, Level 16, State 3, Line 2 Invalid column name 'modify_date'.

is the error i get. and on opening the table it's clear it doen't have any such column with name modify_date. there is another refdate and that too is something else, i have found it redundant