sp_import_metadata

Imports metadata into virtual database using simple and automatic metadata conflict resolution strategy.

Syntax

sp_import_metadata [ @database ] 'database'
   [ , [ @source_schema= ] 'source_schema'
   [ , [ @source_table=  ] 'source_table'
   [ , [ @drop_missing_tables= ] { 0 | 1 } 'drop_missing_tables'
   [ , [ @drop_missing_columns=] { 0 | 1 } 'drop_missing_columns'
   [ , [ @count_rows= ] ] 'count_rows'

Arguments

[ @database = ] ‘database’

Is the name of the target database to import metadata into. The database underlying connection is used as a source of metadata. database is sysname, with no default.

[ @source_schema = ] ‘source_schema’

Is the name of source schema to import with all tables and views in it. source_schema is sysname, with default NULL.

[ @source_table = ] ‘source_table’

Is the name of source table to import. source_table is sysname, with default NULL.

[ @drop_missing_tables = ] ‘drop_missing_tables’

Enable or disable dropping of orphaned tables from the target virtual database. drop_missing_tables is bit, with default 0.

[ @drop_missing_columns = ] ‘drop_missing_columns’

Enable or disable dropping of orphaned columns from the target virtual database. drop_missing_columns is bit, with default 0.

[ @count_rows = ] ‘count_rows’

Enable or disable row count statistic jobs generation. When enabled, for each imported table or view a single-execution job is scheduled that counts the rows and updates statistics. count_rows is bit, with default 1.

Example

The following example creates a virtual database “MyNewVirtualDatabase” using “myConnection”, and imports all metadata using designated the connection.

Note

Example assumes that connection named “myConnection” already exists.

CREATE DATABASE [MyNewVirtualDatabase] WITH CONNECTION [myConnection];

EXEC sp_import_metadata 'MyNewVirtualDatabase', @count_rows = 0;

DROP DATABASE [MyNewVirtualDatabase];