Desktop User Guides > Professional > Table scripting > Working with metadata > Working with versions
 
Working with versions
Sample Script Files: WorkingWithVersions.mrs, RDBTables.mrs.
These example scripts are based on the Short Drinks sample data set. To run examples using the Short drinks sample data set, you need access to a SQL Server installation on which the Short Drinks sample database has been restored, and appropriate user access rights. For more information, see Restoring the Short Drinks sample database. For information on running the example scripts, see Running the sample table scripts.
As a survey progresses, changes are sometimes made to the questionnaire. For example, questions and categories might be added and deleted. Typically a new version is created in the metadata each time a change is made to the questionnaire and each version corresponds to a variation of the questionnaire used for some of the interviews.
By default, when you load a data set that contains more than one version, all of the versions are combined to form a superset (sometimes called a superversion). This means that all of the variables and categories from all of the versions are available. When there is a conflict between, for example, a text in one or more of the versions, the more recent versions generally take precedence over the older versions. It is possible to load a particular version or versions and to change the order of precedence. However the order of questions and categories is always taken from the most recent version.
You select the metadata version you want to load by specifying a version expression (see Version expressions) in the sixth parameter of the DataSet.Load method. The order in which you specify the versions in the expression defines the order of precedence. For example, the following loads version 2:
TableDoc.DataSet.Load("[INSTALL_FOLDER]\IBM\SPSS\DataCollection\7\DDL\ Data\Mdd\short_drinks.mdd", _
, _
"Provider=MSOLEDBSQL.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=short_drinks;Data Source=LocalHost", _
"mrRdbDsc2", _
"short_drinks", _
"{2}")
The following script loads a superset of versions 2 through 4, with the older versions taking precedence over the newer ones:
TableDoc.DataSet.Load("[INSTALL_FOLDER]\IBM\SPSS\DataCollection\7\DDL\ Data\Mdd\short_drinks.mdd", _
, _
"Provider=MSOLEDBSQL.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=short_drinks;Data Source=LocalHost", _
"mrRdbDsc2", _
"short_drinks", _
"{4..2}")
It is important to understand that the version of the metadata you select does not affect the case data that is loaded. However, case data collected using UNICOM Intelligence Interviewer - Server Admin has the name of the version used to collect it stored in the DataCollection.MetadataVersionNumber system variable (see System variables).
See also
Changing the base to reflect the version
Working with metadata