Generating Scripts

You can use Generate Scripts Wizard to create scripts for for a local database, a network database, and for a database on Windows Azure.

Generating a Script

  1. In Database Explorer, expand the node for the instance containing the database to be scripted.
  2. Point to Tasks, and then click Generate Scripts.

  3. On the General page, in the Load a previously saved project section, click Open to select a previously saved *.backup file. If you do not have the project file, go to step 4.
  4. In the Connection list box, select an SQL Server instance.
  5. In the Database list box, select a database.
  6. Click ‘…‘ next to the Path text box, to select a folder to store schema export.
  7. In the Output file name text box, specify a name of the file.
  8. Optionally, you can select the Append timestamp to the file name option to add date-time parameters to the file name.
  9. Optionally, you can select the Use compression (ZIP) option to compress the script file.

  10. On the Script content page, select what do you want to generate. You can also include or exclude specific database objects.

  11. On the Options page, specify how you want this wizard to generate scripts. Many different options are available.

  12. On the Error handling page, specify errors processing behavior and logging options.

  13. Click Generate.

Scheduling a Windows Task

  1. Start Task Scheduler for Windows.
  2. On the Action menu, select Create Basic Task.
  3. Provide Name for the new task. Click Next.
  4. Select one of the options when you want the task to be started. Click Next.
  5. Select time and frequency for starting the task. Click Next.
  6. Select Start a Program and click Next.
  7. Enter the file path in the Program/script field. (The default path is C:\Program Files\Devart\dbForge Studio for SQL Server\

    Task Scheduler

  8. Specify the arguments in the Add arguments field as follows:

    /script /connection:"Data Source=DBMSSQL\MSSQL2012;Integrated Security=False;User ID=sa" /projectfile:"D:\Scripts\AdventureWorks.backup"
  9. Click Next.
  10. Check all specified settings once again and, if no changes are required, click Finish. Otherwise, click Back and make the needed changes.

    Task Creation Finished

Arguments Used in Command Line

Select corresponding command line switches to perform the required operations:

Argument Action and Usage
/connection This switch is used to specify a connection string. Command usage looks like:
/database This switch is used to specify a database to script. It overrides the database specified in the template or in the connection string.
/outputfile This switch is used to specify a file name for storing the database script. It overrides the file name specified in the template.
/password This switch is used to specify a server password. It overrides the password specified in the connection string. Command line usage looks like: /password:<pw>
/projectfile This switch is used to specify a script template to use. Some template options can be overridden by switches.