This worksheet describes how to link between a Snap survey and an SQL Server database, so you can use your existing database to seed your survey, or send updated data from your survey back to your database.

You can set this up to happen automatically by using a Hot Link.

This worksheet describes how to import data from an SQL server database. Exporting data is done in a similar manner.

Background

You can link your Snap survey to a database. This allows you to seed the survey with data that is already in your database, or use email addresses in the database to invite respondents. You can also export data received from the survey back into the database.

This worksheet shows you how to import data from the database to your survey. You can use a similar method to export data from your survey back to the database.

To connect your survey to a database, you need to have a database field that contains a unique ID for each respondent that can be mapped to a respondent variable in the survey, so the data is put in the correct person’s record or response.

Snap can automatically identify many database types. However, some databases have specific requirements, such as password protection. For these, you need to tell Snap precisely how to connect so it can build a data link. You use MicroSoft’s Data Link tool to do this.

Summary of steps

Step 1: Setting up the Database Linkage Wizard
Step 2: Creating the data link for the SQL database
Step 3: Matching records between the survey and the database
Step 4: Choosing what database fields to import into your survey
Setting up a Hot Link to run the link automatically

Step 1: Setting up the Database Linkage Wizard

  1. Make sure that the database or spreadsheet you are importing from is closed.
  2. Open the survey you wish to import the data into.
  3. Click Data Entry window button to open the Data Entry window.
  4. Select File | Database Link to display the Database Linkage dialog.

    Database Linkage

  5. Click [New…] to create a new database link.
  6. The Database Linkage Wizard dialog will be displayed.
  7. Select the Import from Database radio button.

    Database Linkage Wizard

  8. Click [Next>].
  9. The next step in the wizard asks you to select a database file or build a database link. Usually you will be able to click on the [Select Database File] button. If the database type you need is not listed as one of the defaults in the Select Database File dialog box then you can use the [Build Data Link] button to create the connection.
    This worksheet describes how to build a link to an SQL database.
  10. Click the [Build Data Link…] button.

    Database Linkage Wizard, Build Data Link

Step 2: Creating the data link for the SQL database

  1. The Data Link Properties dialog is displayed.You can use the [Help] button on the dialog to display Microsoft’s help on this dialog.
  2. Select the appropriate data type. For a link to an SQL Server database, select Microsoft OLE DB Provider for SQL Server.

    Data Link Properties SQL

  3. Click [Next>]. The Data Link Properties dialog moves to the Connection tab.
  4. Select the SQL server on your network from the dropdown list.
  5. Select the radio button for the appropriate security type for the server.
  6. Select the SQL Server database file from the drop-down list, or type the name of the file.

    Data Link Properties Connect

  7. Click [Test Connection] to confirm that you can connect to your database.
  8. Click [OK]. You will be returned to the Database Linkage Wizard.

Step 3: Matching records between the survey and the database

  1. Select the table or sheet in your database containing the data you want.

    DL wiz: selecting a database file showing customers as the sheet

    Click [Next>].

  2. Select how you will import data to the survey. You will need a unique id for each person in the database that can be matched with a survey respondent (for example, a customer id or email address). This is called the link variable.
    Join cases where the link variables match only imports data from the database if the id is already in the survey.
    Join matching cases and append unmatched cases imports all data from the database. If the id is already in the survey, the appropriate data is added to that case. If it’s not, a new case is created.
    Append unmatched cases creates new cases in the survey for the ids that are not already in the survey. It does not change the existing cases.
    Append all cases creates new cases in the survey for every id in the database. It does not check if the ids are already in the survey.
  3. Select the field in the database that contains the unique id from the Database field dropdown list.

    Database Linkage Wizard cases import / export

  4. Select the variable in the survey that contains the unique id from the Use Snap variable dropdown list. (You can also use the Snap case number as the unique number for each case.)
  5. Click [Next>].

Step 4: Choosing what database fields to import into your survey

When you have chosen the database, database table, and matching variable, you then choose which fields in the database to import. The Database Linkage Wizard dialog shows a list of fields in the database to import from and is shown on the left, with variables in the current survey on the right.

  1. Map the variables between the database and the survey. Snap works out the mapping where possible. To change a mapping, select a row in the right hand column, and click List down to display a list of available variables in the survey. Select a variable to load data into, or select a blank if you do not wish to import the field.

    Data Linkage Wizard Variable Map Import

    If you wish to import a field into your survey that does not already have a variable set up in your survey, select <Create Variable> from the dropdown list. The Name and Label automatically display the name of the database field. You can edit them if you wish. Set the response type and length to appropriate values and click [OK].
    Create Variable

    If you wish to import data into a multi-response variable, you may need to set up which codes in the database match to which variable codes in the survey. When you select the multi-response variable in the right hand column, a code mapping area appears. Select the appropriate code or define a new one as you can with variables.
    Database Linkage Wizard Code Import

  2. Click [Next] to display a summary of what the link does.
  3. Check the details are correct, and enter a Name for the database link.
  4. Click [Finish]. Snap shows the Database Linkage dialog including the new link.
    Database Linkage and New Link

  • If you wish to alter any part of the link, click [Modify]. To delete a link, click [Delete]. To make a copy of the link, click [Clone], and then modify the new link as required.
  • Select the link and click [Run] to import the data. Snap displays a brief report.

Setting up a Hot Link to run the link automatically

Making an import link into a hot link means that when you identify a new case by entering a unique value in the link variable, data from the external file is copied into the new case. This means that details such as name, address and email address could be loaded into the survey as soon as the case was identified.

If it is an export link, the data entered in the Snap survey is copied to the external file. If it is a new case, a new record is created. This allows you to keep a database up to date.

  1. Select File | Database Link to open the Database Linkage dialog.
  2. Select the database link you wish to use.

    Database Linkage and New Link

  3. Click the [Hot Link…] button. The Hot Link dialog appears.
  4. Check the Use As Hot Link box, then select the appropriate option.
    Automatic update: updates the matched variables of each case when the key link field is entered.
    Manual update: update the matched variables when you click the refresh button Refresh button on the Data Entry window toolbar.
    Use As Hot Link / Options

  5. Click [OK]. The Database Linkage dialog shows the amended link specified as a Hot Link.

    Database Linkage and Hot Link

  6. The link will update the survey when the database changes. Click [Run] to update the survey immediately.

Conclusion

This worksheet has described how to connect to your own database to import data to a survey. It describes how to create a data link to connect to a SQL Server database, how to map between the database fields and the survey variables, and how to create new survey variables if necessary. It also describes how to set the database link up as a Hot Link so it automatically updates the database when a new case is imported into the survey.

For instructions on linking to a database containing email addresses, see: Setting up email invites for Snap WebHost using a database link and Setting up a database link for emailing invitations to a Web survey.

For information on using a database link to share information between Snap surveys, see: Importing/exporting data to another Snap survey. To merge surveys using this method, see the worksheet Analysing two surveys together.

If there is a topic you would like a worksheet on, email to snapideas@snapsurveys.com