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
 SQL Server 2005 Forums
 SQL Server Administration (2005)
 Re-applying constrains & defaults

Author  Topic 

nuclearsiloman.com
Starting Member

2 Posts

Posted - 2008-10-03 : 16:41:02
I have a 100 table database that had the constraints and column defaults removed - but the data left intact due to a hack. I have the sql script that originally built the database.

Is there a way to script the existing constraints/column defaults from a duplicate database (or script I have) and apply them to the hacked database thus restoring it to operating condition and keeping the valid data it has?

Thanks.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-10-03 : 16:42:01
Yes. Adding them back in via a script will not impact the data.

Also removing them wouldn't have deleted the data either, so I doubt your "hack" reasoning.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

nuclearsiloman.com
Starting Member

2 Posts

Posted - 2008-10-03 : 16:43:56
Great. So my next question is... is there a way to create a script off the good database that I could then run on the hacked db? Maybe through Enterprise Manager?

It was hacked - I had ~12k injections in it that I had to purge.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-10-03 : 16:49:48
Ah, I didn't understand what you meant by hack.

Yes you can script them inside Enterprise Manager via the Generate SQL script wizard.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -