How to create DDL and DML SQL scripts for specific SQL database objects only

ApexSQL Script is a SQL Server database migration tool which can create SQL scripts by converting SQL database objects and data into a single or multiple deployment SQL scripts, .NET solutions, or executable installers. In many cases when moving a SQL database, there’s no need to migrate the entire SQL database, but only a part of it.

ApexSQL Script offers the possibility to select specific SQL objects and have them included into a sample or testing SQL script. It is even possible to combine multiple SQL databases and extract SQL objects from multiple SQL databases at once.

In the following steps the complete process will be explained:

  1. In the New project window, connect to a desired SQL Server and select databases to choose objects for creating DDL and DML SQL scripts, and click the Load button:

    SQL database selection in the New project window

  2. From the Main grid, it is easy to select only specific SQL objects, and have them included into the required SQL script. Click the Structure view and select objects to include in DDL script:

    Structure view in the main application window

  3. Click the Data view and select objects to include in DML script:

    Data view in the main application window

    If there is no need to include all tables/columns/rows, check out how to narrow the data sub-set for object scripting

  4. After the SQL object selection is complete, the next step for creating SQL script is to click the Script button, located in the Home tab under the Actions section:

    Initiating the Script wizard from the Home tab of the main application window

  5. The process leads on the to the Script wizard, which offers users to set up the Scripting mode and Output type.

    Here, it is possible to select either the Structure (DDL) or Data (DML) scripting mode, or the combination, through the Structure and data mode:

    Choose the Scripting mode in the Script wizard

  6. In the next step of the Script wizard, choose the SQL script as the output type:

    Choose the Scripting mode in the Script wizard

  7. When it comes to scripting, especially if only specific SQL objects are scripted, it is important to process its dependencies. ApexSQL Script ensures that all required dependencies are included and in the following dialog an overview and option to include/exclude specific dependencies are shown:

    Dependencies step in the Script wizard

  8. In the last step, the final adjustments can be made, through the setup of the output file name and its location:

    SQL script options in the Script wizard

  9. Once everything is set, click the Create button and the Results dialog will be shown upon finished process:

    Results dialog with the information about the execution results

ApexSQL Script offers a simple and comprehensive process of creating SQL scripts for both, DML and DDL, making it an easy task even if it is performed repeatedly and frequently.

 

March 5, 2015