Share via


How to: Import a Schema from a Command Prompt

You can import objects and settings from a database or server into a .dbschema file at a command prompt by using the VSDBCMD tool. For more information, see Starting Team Development of Databases that Reference Other Databases. You might use this tool if the computer where you use Visual Studio Premium does not have network access to the database or server from which you want to import objects and settings. To use this tool, you must copy it and the following files either over a network or to a universal serial bus (USB) drive:

  • DatabaseSchemaProviders.Extensions.xml

  • Microsoft.Data.Schema.dll

  • Microsoft.Data.Schema.ScriptDom.dll

  • Microsoft.Data.Schema.ScriptDom.Sql.dll

  • Microsoft.Data.Schema.Sql.dll

  • Microsoft.Data.Schema.Utilities.dll

  • Microsoft.SqlServer.BatchParser.dll

  • Sqlceer35en.dll

  • Sqlceme35.dll

  • Sqlceqp35.dll

  • Sqlcese35.dll

  • System.Data.SqlServerCe.dll

  • VSDBCMD.EXE

Important

To use VSDBCMD.EXE on a computer on which you have not installed Visual Studio, you must install the version of Microsoft.SqlServer.BatchParser.dll that matches your version of SQL Server. For SQL Server 2008, that file is installed when you install any of the following software:

You can specify additional arguments at the command prompt. For more information, see Command-Line Reference for VSDBCMD.EXE (Deployment and Schema Import).

Important

You cannot use VSDBCMD to import objects and settings into a data-tier application component (DAC) project. You must use the Import DAC or Import Script commands from within Visual Studio. For more information, see How to: Import Database Objects from a Script, and the following pages on the Microsoft Web site.

Special Requirements for 64-bit Operating Systems

If you want to deploy by using VSDBCMD.EXE on a computer that has a 64-bit operating system, you must install both the 32-bit and the 64-bit versions of the SQL CE assemblies listed earlier in this topic. To install the necessary files, see the following page on the Microsoft web site: Download details: Microsoft SQL Server Compact 3.5 Service Pack 2 for Windows Desktop.

Note

You do not have to deploy from your production server. You can use any computer from which you can connect to the target server and database, such as a staging computer.

BadImageFormatException

If a BadImageFormatException occurs when you run VSDBCMD.EXE, you can resolve the issue if you install Microsoft .NET Framework 4. For more information, see the following page on the Microsoft web site: Download details: Microsoft .NET Framework 4 (Standalone Installer).

To copy the supporting files to your USB drive

  1. Navigate to the Program Files\Microsoft Visual Studio 10.0\VSTSDB\Deploy folder, and copy the contents of that folder to your USB drive.

  2. Navigate to the Program Files\Microsoft SQL Server Compact Edition\v3.5 folder, and copy the DLLs that are listed earlier in this topic to your USB drive.

    Next you use these files to import objects and settings for a database or a server.

To import database objects and settings by using VSDBCMD

  • Open a Command Prompt window, and type the following command line.

    VSDBCMD /a:Import /cs:" ConnectionString" /dsp:Sql /model:DatabaseName.dbschema
    

    For DatabaseName, you specify the name that you want to give to the .dbschema file.

    For ConnectionString, specify the connection string to the target database, including the database name. For example, to import the AdventureWorks2008 database, you might specify /cs:"Data Source=MyServer/SQL2K8;Integrated Security=True;Pooling=False;Initial Catalog=AdventureWorks2008".

To import server objects and settings by using VSDBCMD

  • Open a Command Prompt window, and type the following command line:

    VSDBCMD /a:Import /cs:" ConnectionString" /dsp:Sql /model:ServerName.dbschema
    

    For ServerName, you specify the name that you want to give the .dbschema file.

    For ConnectionString, specify the connection string to the database from which you want to import. You specify master as the database name. For example, you might specify /cs:"Data Source=MyServer/SQL2K8;Integrated Security=True;Pooling=False;Initial Catalog=master".

See Also

Reference

Command-Line Reference for VSDBCMD.EXE (Deployment and Schema Import)

Concepts

Build and Deploy Databases to a Staging or Production Environment