2

I'm looking for a tool or some way to generate tables scripts without constraint for a SQL server 2005 DB. My goal is make a snapshot of DB having one script file for each table with create and insert statements. I want to create a new DB just using these script files, but in order ti run them, the table scripts must not have any constraints.

Thanks Dom

CDominik
  • 115
  • 1
  • 10
  • 2
    Right Click Database -> Generate Script -> In Options choose what you want selecting true/false (http://i.stack.imgur.com/pWNr4.png) – Lukasz Szozda Aug 23 '15 at 18:00
  • Database -> RC -> Tasks -> Generate Script – Lukasz Szozda Aug 23 '15 at 18:06
  • @ lad2025, do you mean from Management Studio? actually, I didn't find any option to include/exclude constraints. "script check constraints" it's not related to the creation constraint part, but it's just for check before inserting data – CDominik Aug 23 '15 at 18:44
  • Yes SSMS, second thing you can create script with constraints but disabled and after INSERTING data just enable them. [Temporary disable constraints](http://stackoverflow.com/questions/737115/turn-off-constraints-temporarily-ms-sql) or [here](http://stackoverflow.com/questions/159038/how-can-foreign-key-constraints-be-temporarily-disabled-using-t-sql/161410#161410) – Lukasz Szozda Aug 23 '15 at 19:46
  • ok let's supposoe that I have a file script for each table within constraints are disable until the the end of the inserting, I'm wondering if I will get an error if there is another table with enabled constraints related to the current – CDominik Aug 24 '15 at 08:07
  • I'm not sure if I understand you correctly. Please attach example what you get when generating script and what is desired output. – Lukasz Szozda Aug 24 '15 at 11:40
  • @lad2005, maybe I found solution; option Script Foreign Key = false avoid to generate the constraint of the relationship. tks – CDominik Aug 25 '15 at 17:53

0 Answers0