How can we compare stored procedures in two databases

  • We have two databases that may contain different versions of stored procedures.

    Is there any was in which we can find out the differences automatically?

    Eg. Last modified date

    Many thanks

    Chris Chamberlain

  • You can query the sys.objects catalog view for creation date as well as last updated.

    You can also query the sys.sql_modules catalog view for the definition.

    A good 3rd party tool would be redgate's SQL Compare. We use it all the time here.

  • Personally I'd use the "generate script" and WinDIFF. This way you get to both find things that are different, and get right to the area of code where they ARE different.

    If you're simply looking to get the names, Run this on both databases, then compare the hashcodes (join by objectname)

    select so.name objectname,

    sc.text objecttext,

    hashbytes('SHA1',sc.text) hashcode

    from sys.syscomments sc

    inner join sys.objects so on sc.id=so.object_id

    ----------------------------------------------------------------------------------
    Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply