MISSING CONSTRAINTS AND TRIGGERS

  • Hi,

    I am trying a fix a database that is missing constrainsa and triggers that sould be present according to an old backup.

    Does anyone have the know how create a script that would extract triggers and constraints from an old database to a file that can then be run into the broken database?

    I cannot overwrite the working database as it has a lot of data in it.

    Your help would be appreciated.

    I rather not do this manually for each trigger and constaint.

    Thanks in advance.

  • Download a free trial of ApexSQL Diff, or RedGate Compare, and that will find the missing stuff and create a script that will do all of the fixing for you. Either one is easy to use and very, very useful to a DBA.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • Let me get on my soap box.

    If you were to have scripts in source control for every object in your database this would be a non issue. 🙂

    Getting off my soap box...

    GSquared is right. The RedGate software is great. Another option is as follows...

    I would simply have management studio script out all the objects of your old database to separate files. Then do the same with the new one (in a different directory). Then use WINDIFF or ExamDIFF Pro (my preference) to compare the directories/files. Now, run the missing scripts on the new database and away you go. Plus you are all set to start putting the scripts into a source control database 🙂

    Gary Johnson
    Sr Database Engineer

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

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