How_to_script_your_db.txt 2.31 KB
The following instructions demonstrate how to script your database into MD3 compatible SQL files
You don't need to do each of these steps unless you want that object under MD3 control.  

1. Script your tables.  
	You can do this with the native table scripter in SSMS.  
	follow the instructions in Tables\_readme.txt
2. 	Script your Primary Keys
	--find a pristine copy of your database and install the MD3 objects
	--EXEC MD3.RepopulatePrimaryKeys  --this will repopulate the MD3.PrimaryKeys table
	--EXEC MD3.ScriptPrimaryKeys  --produces PRINT statements to script out all PKs.  Save the output to the PrimaryKeys folder
	An example file is found in the PrimaryKeys folder
3. 	Script your Indexes
	--find a pristine copy of your database and install the MD3 objects
	--EXEC MD3.RepopulateIndexes  --this will repopulate the MD3.Indexes table
	--EXEC MD3.ScriptIndexes  --produces PRINT statements to script out all Indexes.  Save the output to the Indexes folder
	An example file is found in the Indexes folder
4. 	Script your Foreign Keys
	--find a pristine copy of your database and install the MD3 objects
	--EXEC MD3.RepopulateForeignKeys  --this will repopulate the MD3.ForeignKeys table
	--EXEC MD3.ScriptForeignKeys  --produces PRINT statements to script out all FKs.  Save the output to the ForeignKeys folder
	An example file is found in the ForeignKeys folder
5. 	Script your Check Constraints
	--find a pristine copy of your database and install the MD3 objects
	--EXEC MD3.RepopulateCheckConstraints  --this will repopulate the MD3.CheckConstraints table
	--EXEC MD3.ScriptCheckConstraints  --produces PRINT statements to script out all check constraints.  Save the output to the CheckConstraints folder
	An example file is found in the CheckConstraints folder	
6. 	Script your Defaults
	--find a pristine copy of your database and install the MD3 objects
	--EXEC MD3.RepopulateDefaultConstraints  --this will repopulate the MD3.DefaultConstraints table
	--EXEC MD3.ScriptDefaultConstraints  --produces PRINT statements to script out all default constraints.  Save the output to the DefaultConstraints folder
	An example file is found in the DefaultConstraints folder	
7.  You can then choose to script your Triggers, schemas, filegroups, partition functions/schemes, users, etc and place them in the correct folders.