One thing to know about is that you need to create objects in a dependent order. Therefore, you cannot just iterate over files.
As a result, we got a batch file in which all objects will be listed in the order of dependence
In fact, we had 2 batch files called createDBObject.bat:
:: Parameters Required: :: %1 UserID :: %2 Password :: %3 Server :: %4 Database :: %5 file with scripted object :: echo. >> CreateDBObjectsLog.txt echo %5 >> CreateDBObjectsLog.txt osql -U%1 -P%2 -S%3 -i%5 -d%4 -n >> CreateDBObjectsLog.txt echo * %5
and then another with a list of all db objects:
:: Parameters Required: :: %1 UserID :: %2 Password :: %3 Server :: %4 Database :: echo object in %4 database on %3 server echo Please Wait ... if exist CreateDBObjectsLog.txt del CreateDBObjectsLog.txt call createDBObject.bat %1, %2, %3, %4, ScriptedTable1 call createDBObject.bat %1, %2, %3, %4, ScriptedTable2 ... call createDBObject.bat %1, %2, %3, %4, ScriptedTableN call createDBObject.bat %1, %2, %3, %4, ScriptedView1 call createDBObject.bat %1, %2, %3, %4, ScriptedSP1 etc
Now we use SQL Compare Pro , which automates all these tasks.
You can also check the relevant question: Is there a RedGate alternative for "poor mana" to script the entire database schema?