Select only a set of tables
martijnbrein
Posts: 2
Hi,
The example from Automating SQL Packager makes it possible to build a package from the whole database (tables views stored procedures users).
I only need to package a few tables from my database. How is this possible in the example?
I found this in the help file:
excludeschema
All - All database objects
Table - Tables
View - Views
StoredProcedure - Stored procedures
Default - Default.
FullTextCatalog - Full text catalogs
Function - User-defined functions
Role - Roles
Rule - Rules
User - Users
UserDefinedType - User-defined data types
To create an executable package including only tables whose names include the word "Product"
SQLPackager /database1:FirstDatabaseName /makeexe ↵
/name:PackageName /location:TargetDirectoryName /includetypes:table ↵
/include:table:Product
I hope somebody can help me
The example from Automating SQL Packager makes it possible to build a package from the whole database (tables views stored procedures users).
I only need to package a few tables from my database. How is this possible in the example?
I found this in the help file:
excludeschema
All - All database objects
Table - Tables
View - Views
StoredProcedure - Stored procedures
Default - Default.
FullTextCatalog - Full text catalogs
Function - User-defined functions
Role - Roles
Rule - Rules
User - Users
UserDefinedType - User-defined data types
To create an executable package including only tables whose names include the word "Product"
SQLPackager /database1:FirstDatabaseName /makeexe ↵
/name:PackageName /location:TargetDirectoryName /includetypes:table ↵
/include:table:Product
I hope somebody can help me
Comments
You'll probably want to have a look at the Packager API examples that come with the SQL Bundle. They are normally found in c:\program files\red gate\sql bundle 5\Toolkit Sample Files.
There is a Packager example (packagedatabase.cs). With a few changes, you could use this. If you look in the SetSchemaExecutionBlock method, there is a block where you can select individual schema blocks: You could, for instance, narrow this down to only tables or only tables with a certain name: Then, make sure that you change the mappings for the data. Right after the CreateMappings method runs, you could limit the selected tables there: Hopefully this points you in the right direction.