=================================================================
====          MS SQL Server import scripts                   ====
====               for Catalogue of Life                     ====
====           Darwin Core Archive Downloads                 ====
=================================================================

Author: Ayco Holleman
Copyright: ETI BioInformatics
Developed in: OpenUp! project Work Package 4 for Task 4.1
Version 1.0, 2012



Synopsis
=================================================================
create.sql and import.sql will help you import files generated by
the Darwin Core Archive (DWC-A) download service into Microsoft
SQL Server.




create.sql
=================================================================
create.sql creates 4 tables, one for each file generated by the
DWC-A exporter:

* Taxon
* Distribution
* Reference
* VernacularName

You can optionally specify a prefix for the table names (for
example when you want them to be created in a database that
already contains other tables). To do so, set the variable
@table_prefix at the top of the script as appropriate.

Note that create.sql will not create the database itself. You
must do that yourself.




import.sql
=================================================================
import.sql imports the files generated by the DWC-A exporter into
the tables created by create.sql.

Before running this script you MUST first set the variable at the
top of the script (@export_dir) to the directory where you
unzipped the DWC-A zip file. In other words, you must set
@export_dir to the directory containing taxa.txt,
distribution.txt, reference.txt and vernacular.txt. You MUST end
the directory path with a backslash ('\') !

If you specified a table prefix in create.sql, you must specify
the same table prefix in import.sql




Running the Scripts
=================================================================
* Open SQL Server Management Studio and connect to the
* Open the scripts in SQL Server Management Studio
* Select the database in which to run the scripts
* If the database does not yet contain the tables, run
  create.sql; otherwise you can skip this step. Run create.sql by
  clicking on the create.sql tab and press Execute
* Click the import.sql tab and press Execute





