Importing SQL Scripts in to the Database Project

One of the new things you will find in CTP5, is the Import Script Wizard. This wizard allows you to select a existing .SQL script file and import the DDL statement in to the database project as schema objects.

First you select an existing SQL script file. 

When you have selected an existing file, the Finish button enables and the wizard will take it from there. It will first parse the script file. As you can see in the Summary page below, when loading the good old INSTPUBS.SQL file from SQL Server 2000, it contains 81 batches and 355 statements, not all of these are DDL statement though. The we will check if a statement represents a DDL fragment, and if so we will turn it in to a schema object in the database project.

The Import Script functionality is basically doing the same as Import Schema, only instead of pulling schema from a database it gets extracted from a script file.

There are some minor differences. The main one being that the Import Schema option can only be executed once when there are no schema objects in the project; which is Import Schema is now part of the New Project Wizard. Import Script can be called many times, over and over again to add objects to the project. This means you can load the same file twice which will results in errors in the error list, indicating that you are trying to create duplicate entries.

Like Import Schema does not change the source database, Import Script does not change the input file; we simply shred the input stream and filter out the DDL statements.

This is the first incarnation of the Import Script Wizard, the next version will add a selection UI, which will show an overview of all the DDL objects detected in the script file; if the object does not exist in the project we will default to an Add operation (which you can change to Ignore if you do not want to add the object to the project). If the object does exist it defaults to Ignore the script unless you choose the Overwrite operation. This way you get more control, prevent errors and cherry pick these objects you want to import in to the database project, but this will show up in CTP6.

That's it for now, back to getting CTP5 ready for release (next week),
"DataDude" Development Manager