19.10.2. copy tableContents

Copies the contents of a given table to another table, which may reside in another database type, so allows you to copy table contents database-independently. E.g. you may copy the contents of a table from a MSSQL database to a table in an Oracle database. All datasource types supported by ReportServer are supported.

The destination table must exist and must contain the same fields as the source table. Their field types must be compatible.

You can locate your datasources by using an object resolver query. Refer to Section 15.5. Object Resolver for more details of object resolver queries.

Refer to the following example:

copy tableContents id:DatabaseDatasource:58 RS_SCHEMAINFO id:DatabaseDatasource:60 myschemainfo entity_id false 200

The example copies the contents of the RS_SCHEMAINFO table of your internal datasource with id 58 into a table with name myschemainfo in the datasource with id 60.

Again, note this is database-independent. In the example above the datasource with id 58 is a MSSQL datasource, while the datasource with id 60 is an Oracle datasource.

The command prints some information for you to be able to see what is happening in the background. In the example above the information printed is:

Status OK
All columns [ENTITY_ID, KEY_FIELD, VALUE]
Datatypes [-5, 12, 12]
Indexes of primary keys [0]
SELECT statement SELECT ENTITY_ID,KEY_FIELD,VALUE FROM RS_SCHEMAINFO
INSERT statement INSERT INTO myschemainfo (KEY_FIELD,VALUE) values (?,?)
Total duration 0.987 seconds

If your table contains a compound primary key, you can enter it in a ;-separated list. E.g.:

copy tableContents id:DatabaseDatasource:58 RS_SCHEMAINFO id:DatabaseDatasource:60 myschemainfo myKey1;myKey2 false 200

As both source and destination tables should contain the same fields, the primaryKeys should exist in both.

The copyPrimaryKeys should be true if primary key values should be copied to the destination table, else false. For primary key fields in the destination table which are calculated by your database (auto-increment, etc), this should be false in order for the database to calculate them instead of the command copying them.

The batch size is the packet size in the batch-insert. This is optional. Default is 100.

Use: copyTableContents sourceDatasource sourceTable destinationDatasource destinationTable primaryKeys copyPrimaryKeys [batchSize]