How to: Create the Mobile Staging Database, Database Objects, and the Mobile Staging Publication for Mobile Sales

Microsoft Dynamics Mobile - Device Components provides SQL scripts that create all the objects needed for the mobile staging database for Mobile Sales. Use the following procedures to prepare for and to create the database. One of the scripts sets up replication between the server and the mobile applications. For more information, see Working with Replication.

The following figure illustrates the mobile staging database and the publication within the mobile architecture.


For more information about installing Mobile Sales and the SQL scripts, see How to: Install Microsoft Dynamics Mobile - Device Components.

To prepare to create the mobile staging database

  1. On the computer that is installed with Mobile Sales, locate the folder that contains the SQL scripts as follows.

    1. Click Start, and then point to All Programs.

    2. Point to Microsoft Dynamics Mobile, and then click Folder Overview.

      This opens the folder in which you installed the Microsoft Dynamics Mobile - Device Components files. The default location is C:\Program Files\Microsoft Dynamics Mobile.

    3. Open the following folder:

      Solutions\Microsoft Dynamics\Mobile Sales\Server\Staging Database

      where Microsoft Dynamics matches the Microsoft Dynamics solution that you are integrating with.

  2. Familiarize yourself with the contents of the following three scripts that found in the folder.

    Script For more information, see

    1 Create Mobile-Staging - Database.sql

    Create Mobile Staging Database Script

    2 Create Mobile-Staging - Database objects.sql

    Create Mobile Staging Database Objects Script

    3 Create pubMobile-Staging - Replication.sql

    Create Stored Procedure for Mobile Price Calculation Script

  3. Optionally, configure the first script. For more information, see Create Mobile Staging Database Script.


    If you change the name of the mobile staging database in the first script, you must also update the other scripts accordingly, and you must change the name of the publication in the app.config file for the mobile application.

  4. Ensure that the SQL Server Agent service is running.

  5. Use the following procedure to execute the scripts on the database server in this order:

To create the mobile staging database

  1. Copy the script files to the database server.


    Ensure that you access the scripts in the folder that applies to the Microsoft Dynamics business application that you are integrating with.

  2. In SQL Server Management Studio, connect to the database server that you will use for the staging database.

  3. Locate the SQL script file named 1 Create Mobile-Staging - Database.sql and double-click the file.

    A new query opens.

  4. In the toolbar, click Parse.

  5. In the toolbar, click Execute.

  6. Repeat the steps 3 to 5 for the remaining script files:

    • 2 Create Mobile-Staging - Database objects.sql

    • 3 Create pubMobile-Staging - Replication.sql

The mobile staging database and a publication for the database are created. Next, you must assign the appropriate permissions for the database and publication to mobile users. For more information, see How to: Assign Permissions on the Mobile Staging Database and the Mobile Staging Publication.

Working with Replication

Mobile Sales includes a script that creates the publication that publishes reference data from the staging database to the subscribers. The publication includes all tables required by the mobile application.

To view the published tables

  1. Open the Microsoft SQL Server Management Studio.

  2. Click Replication, and then click Local Publications.

  3. Right-click [Mobile Staging]: pubMobile-Staging, and then click Properties.

  4. In the Publication Properties page, click Articles.

  5. To view the filtered tables, in the Publication Properties page, click Filter Rows.

The Articles page contains a list of all published tables. Additional tables can be added if required. Some of the tables are filtered and the availability of data in these tables depends on the user credentials supplied during synchronization. These credentials match the credentials listed in the Users table under the Filter Rows page. The unfiltered tables make the data available to all users who have access to and subscribe to the publication.


You must grant users access to the publication. For more information, see How to: Assign Permissions on the Mobile Staging Database and the Mobile Staging Publication.

Changing the Expiration Date

By default, the publications expire after two weeks. Change this setting as required. For example, you can set the publication to never expire or change the expiration period. Select the setting based on how often users synchronize. If the publication is set to never expire then users who no longer subscribe to the database are still subject to maintenance. This may not be the desired outcome, especially in scenarios with a large number of mobile users.

To change the expiration setting

  1. In Microsoft SQL Server Management Studio, right-click the publication you want to change the expiry period for, and then click Properties.

  2. On the General page, change the settings under Subscription expiration.

  3. Click OK.

See Also

Community Additions