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.

  1. In the New project window, select databases to choose objects for creating DDL and DML SQL scripts, and click the Open button:

  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:

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

  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:

  5. The process leads on the next dialog, which is offering to set up the Scripting mode and Output type.

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

  6. 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:

  7. In the last dialog window, the final adjustments can be made, through the setup of the output file and its location, by using the Create and write to file option or the Create and check in to Source Control option. This will add to the process simplicity and time saving if the SQL script needs to be checked into the source control immediately upon creation:

    There are more options in the Output file tab, like scripting multiple objects into a single file, or scripting each object into an individual file. It is possible to create a SQL script for each SQL database selected at the beginning of the process, including additional details like Filename template, containing customized name tags. Also, there is an option to Alter database name:

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