Reverse Engineer a database from the command line.


I am attempting to take a database on a SQL server instance on my machine and, from the command line, have TDM create a new model, reverse engineer the DB into the new model, and save out the model file.

I have been able to launch toad with a blank model but I have not yet found a way to execute the appropriate scripts to preform the Reverse engineering.

Any help is appriciated.

Thank you,



you can find an example in the Help file. See attached screenshot.



Thanks for pointing me in the right direction. I am having a little trouble with the example from the help file though. When I run the example, the script throws an error at the following line from the LoadPackagesByModelDefName, because MDef is null:


I’ve added some debugging statements and the GetObjectByName(AName) call is returning null when caled with AName = ‘Microsoft SQL Server 2008’

Am I using the wrong Model Definition name or do I have something else wron with my scripts?

Thanks again,



I have several questions for you:

  1. What version of Toad Data Modeler do you use?

  2. What is the name of your stored alias (TDM 4.x) or connection (TDM 5) ?

(Please provide screenshot, if possible.)

  1. Did you install the software with all supported database platforms, please? (During installation you can choose database platforms. Ideally, install all items).


I have tried running this in Toad Data Modeler 4.3, as well as in version

The Alias I created is called “DJE-alias1”. It connects to a DB on my local machine and is set to revese engineer the entire DB (Entities, Relationships, etc.)


I know that version 5.0.5 was installed with all the database platforms, and I believe that 4.3 was as well, though its been a while since I installed it.

The script that I am running from the scripting window in Toad 5.0.5 is attached. Please forgive the debuging message boxes.

Let me know if you need further detail of the Alias/Connection.

Thanks again,

ToadREScrpt.txt (3 KB)


please use MS SQL Server 2008 instead of Microsoft SQL Server 2008. We used to use MS abbreviation in past and then changed the caption from MS to Microsoft.

var Model = RE(‘DJE-alias1’, App, ‘Microsoft SQL Server 2008’);
var Model = RE(‘DJE-alias1’, App, ‘MS SQL Server 2008’);

To find out correct model def, do the following:

  1. Create new model for selected targret database.
  2. Enable Expert Mode in Settings.
  3. Click Expert Mode | Scripting Window
  4. Add your model to right side
  5. Run the following script

function main(){




I hope it helps,


I figured that it was something like that. After correcting that the script is working correctly.

Thank you very much for your help.


My pleasure :slight_smile: