Altova DatabaseSpy 2023 Enterprise Edition

Populating Other Tables (Optional)

Home Prev Top Next

In the previous steps of this tutorial, you have imported data into the database from a text file as well as from an XML file. This has populated the tblZookeepers and tblFeedSuppliers tables with data.

 

Optionally, to populate the remaining database tables with data, run an import from the following text or XML files available in the C:\Users\<username>\Documents\Altova\DatabaseSpy2023\DatabaseSpyExamples\Tutorial folder. For each table, you should import data from either the CSV or the XML file (not both).

 

CSV files

XML files

1.tblAnimalFeed.txt

2.tblFeedingSchedules.txt

3.tblAnimals.txt

4.tblVeterinarians.txt

5.tblAnimalBirths.txt

6.tblMedicalTreatments.txt

1.dbo.tblAnimalFeed.xml

2.dbo.tblFeedingSchedules.xml

3.dbo.tblAnimals.xml

4.dbo.tblVeterinarians.xml

5.dbo.tblAnimalBirths.xml

6.dbo.tblMedicalTreatments.xml

 

Note that the source files contain foreign key values that are supposed to exist in the target database tables at the time of import. For example, table tblAnimals must be populated before tblMedicalTreatments, because one cannot add a medical treatment record for an animal ID that does not exist yet in the database. Therefore, for the import to be successful, make sure that:

 

1.The files are imported in the order shown above.

2.No data has been previously added or deleted from the destination table (in other words, the table must have an identity value of 0).

 

If you discover that the import fails due to foreign key constraint violations, it is likely that data has already been added or deleted in the table. To remedy this, delete all data from the table, reset the identity value to 0, and then perform the import again. The following code listing shows how to reset the identity value of a SQL Server table to 0:

 

USE ZooDB;  

GO  

DBCC CHECKIDENT ('tblVeterinarians', RESEED, 0);  

GO

© 2017-2023 Altova GmbH