如何使用SQL Server导入和导出向导将数据导入/导出到SQL Server

时间:2024-03-29 10:47:36

This article will explain the steps for importing and exporting data using the SQL Server Import and Export Wizard.

本文将介绍使用SQL Server导入和导出向导导入和导出数据的步骤

Depending on the options that are selected in the SQL Server Import and Export Wizard, some steps may be different than those described in this article.

根据在SQL Server导入和导出向导中选择的选项,某些步骤可能与本文中介绍的步骤有所不同。

For the purpose of this example, exporting data from the SQL Server database to an Excel file will be shown.

就本示例而言,将显示将数据从SQL Server数据库导出到Excel文件的过程。

There are several ways to initiate the SQL Server Import and Export Wizard:

有几种方法可以启动SQL Server导入和导出向导:

开始菜单 (Start menu)

In the Start menu, type the word Import or Export and choose one of the offered:

在开始菜单中,输入单词Import或Export,然后选择以下选项之一:

如何使用SQL Server导入和导出向导将数据导入/导出到SQL Server

Or, in the Start menu under the Microsoft SQL Server 2017, choose one of the offered options:

或者,在Microsoft SQL Server 2017下的“ 开始”菜单中,选择提供的选项之一:

  • SQL Server 2017 Import and Export Data (32-bit)

    SQL Server 2017导入和导出数据(32位)
  • SQL Server 2017 Import and Export Data (64-bit)

    SQL Server 2017导入和导出数据(64位)

如何使用SQL Server导入和导出向导将数据导入/导出到SQL Server

命令提示符 (Command prompt)

In the Command prompt, type the following: C:\Program Files\Microsoft SQL Server\140\DTS\Binn\ DTSWizard.exe for the 64-bit version:

命令提示符下,键入以下内容:64位版本的C:\ Program Files \ Microsoft SQL Server \ 140 \ DTS \ Binn \ DTSWizard.exe

如何使用SQL Server导入和导出向导将数据导入/导出到SQL Server

Or, type the following C:\Program Files (x86)\Microsoft SQL Server\140\DTS\Binn DTSWizard.exe for the 32-bit version.

或者,为32位版本键入以下C:\ Program Files(x86)\ Microsoft SQL Server \ 140 \ DTS \ Binn DTSWizard.exe

Or, go to above mentioned locations and, from there, run DTSWizard.exe:

或者,转到上述位置,然后从那里运行DTSWizard.exe:

如何使用SQL Server导入和导出向导将数据导入/导出到SQL Server

SQL Server管理Studio(SSMS) (SQL Server Management Studio (SSMS))

To start the SQL Server Import and Export Wizard using SSMS, go to Object Explorer, right click on a database for which want to export or import data; from the context menu under the Task sub-menu, choose the Import Data or Export Data option:

要使用SSMS启动SQL Server导入和导出向导,转到对象资源管理器中 ,为此要导出或导入数据的数据库上点击右键; 从“ 任务”子菜单下的上下文菜单中,选择“ 导入数据”或“ 导出数据”选项:

如何使用SQL Server导入和导出向导将数据导入/导出到SQL Server

The latest version of SSMS can be downloaded from the Download SQL Server Management Studio (SSMS) page

可以从“ 下载SQL Server Management Studio(SSMS)”页面下载最新版本的SSMS。

SQL Server数据工具(SSDT) (SQL Server Data Tools (SSDT))

Another way to launch the SQL Server Import and Export Wizard is by using SQL Server Data Tools (SSDT) via Visual Studio.

启动SQL Server导入和导出向导的另一种方法是通过Visual Studio使用SQL Server数据工具(SSDT)。

SQL Server Data Tools (SSDT) can be downloaded from the Download SQL Server Data Tools (SSDT) page:

可以从“ 下载SQL Server数据工具(SSDT)”页面下载SQL Server数据工具(SSDT)

如何使用SQL Server导入和导出向导将数据导入/导出到SQL Server

Under the Integration Services project:

在Integration Services项目下:

如何使用SQL Server导入和导出向导将数据导入/导出到SQL Server

Go to the Project menu and choose the SSIS Import and Export Wizard option:

转到“ 项目”菜单,然后选择“ SSIS导入和导出向导”选项:

如何使用SQL Server导入和导出向导将数据导入/导出到SQL Server

Or in Solution Explorer, right click the SSIS Packages folder and, from the context menu, choose the SSIS Import and Export Wizard option:

或在解决方案资源管理器中 ,右键单击“ SSIS软件包”文件夹,然后从上下文菜单中选择“ SSIS导入和导出向导”选项:

如何使用SQL Server导入和导出向导将数据导入/导出到SQL Server

The common warning message that appears when using the SQL Server Import and Export Wizard is:

使用“ SQL Server导入和导出向导”时出现的常见警告消息是:

The operation could not be completed.

操作无法完成。

“ADDITIONAL INFORMATION:
The ‘Microsoft.ACE.OLEDB.12.0’ provider is not registered on the local machine. (System.Data)”

“附加信息:
“ Microsoft.ACE.OLEDB.12.0”提供程序未在本地计算机上注册。 (系统数据)”

如何使用SQL Server导入和导出向导将数据导入/导出到SQL Server

This happens because of the choice of the wrong version (32-bit or 64-bit) of the SQL Server Import and Export Wizard. For example, if exporting data from the 64-bit version of SQL Server and using the SQL Server Import and Export Wizard via SSMS which is 32-bit application and include 32-bit version of the SQL Server Import and Export Wizard and, because of that, the above warning message will appear. To resolve this, launch 64-bit version of the SQL Server Import and Export Wizard.

发生这种情况的原因是选择了错误SQL Server导入和导出向导版本(32位或64位)。 例如,如果从64位版本SQL Server导出数据并通过SSMS使用SQL Server导入和导出向导(SSMS是32位应用程序,并且包括32位版本SQL Server导入和导出向导),并且由于那,上面的警告信息将会出现。 若要解决此问题,启动SQL Server导入和导出向导的64位版本。

Bear in mind that SQL Server Data Tools (SSDT) is a 32-bit application, too.

请记住,SQL Server数据工具(SSDT)也是32位应用程序。

Also, when the SQL Server Import and Export Wizard is used, make sure that you have adequate permissions, otherwise one of the following messages may appear:

另外,使用“ SQL Server导入和导出向导”时,请确保您具有足够的权限,否则可能会出现以下消息之一:

如何使用SQL Server导入和导出向导将数据导入/导出到SQL Server

More about necessary permissions in order to use the SQL Server Import and Export Wizard successfully can be found on this page

可以在此页面上找到有关成功使用SQL Server导入和导出向导的必要权限的更多信息。

The SQL Server Import and Export Wizard uses SQL Server Integration Services (SSIS) to copy data. The SQL Server Import and Export Wizard creates an SSIS package in the memory while you set the options in the wizard. In the end, provide an option to save the SSIS package:

SQL Server导入和导出向导使用SQL Server集成服务(SSIS)复制数据。 当您在向导中设置选项时,SQL Server导入和导出向导会在内存中创建一个SSIS包。 最后,提供一个保存SSIS包的选项:

如何使用SQL Server导入和导出向导将数据导入/导出到SQL Server

More about SSIS package can be found on the SQL Server Integration Services page.

SQL Server Integration Services页上可以找到有关SSIS包的更多信息。

After launching the SQL Server Import and Export Wizard Welcome page, the following will appear:

启动“ SQL Server导入和导出向导的欢迎”页面后,将显示以下内容:

如何使用SQL Server导入和导出向导将数据导入/导出到SQL Server

To prevent this page to appear next time when the SQL Server Import and Export Wizard is launched, check the Do not show this starting page again. checkbox.

为防止下次启动SQL Server导入和导出向导时出现此页面,请选中“不再显示此起始页面”。 复选框。

To proceed, click the Next button, the Choose a Data Source page will be shown:

要继续,请单击“ 下一步”按钮,然后选择“选择数据源”。 页面将显示:

如何使用SQL Server导入和导出向导将数据导入/导出到SQL Server

On this page, the info about data source and how to connect to the data source must be provided.

在此页面上,必须提供有关数据源以及如何连接到数据源的信息。

From the Data source combo box, select the data provider that will connect to the data source. The name of the data provider typically contains a name of the data source. For example, the data driver for connecting to SQL Server is SQL Server Native Client 11.0 or for connecting to the Excel files is Microsoft Excel etc.

在“ 数据源”组合框中,选择将连接到数据源的数据提供程序。 数据提供者的名称通常包含数据源的名称。 例如,用于连接到SQL Server的数据驱动程序是SQL Server Native Client 11.0,或者用于连接到Excel文件的数据驱动程序是Microsoft Excel等。

如何使用SQL Server导入和导出向导将数据导入/导出到SQL Server

The Data source combo box lists only the data providers that are installed on your machine. Also, if the 64-bit SQL Server Import and Export Wizard is used in the Data source combo box, won’t be listed installed 32-bit providers.

数据源组合框仅列出计算机上安装的数据提供程序。 另外,如果在“数据源”组合框中使用了64位SQL Server导入和导出向导,则不会列出已安装的32位提供程序。

Pressing the F1 key from the keyboard while on any page of the SQL Server Import and Export Wizard will open the corresponding documentation for that page.

在SQL Server导入和导出向导的任何页面上,从键盘上按F1键将打开该页面的相应文档。

The same thing can be achieved by clicking the Help button on the SQL Server Import and Export Wizard pages:

通过单击“ SQL Server导入和导出向导”页面上的“ 帮助”按钮,可以实现相同的目的:

如何使用SQL Server导入和导出向导将数据导入/导出到SQL Server

Options that will be shown on the SQL Server Import and Export Wizard pages depend on the selected data source in the Data source combo box.

将在“ SQL Server导入和导出向导”页面上显示的选项取决于在“数据源”组合框中选择的数据源。

In our example, the SQL Server Native Client 11.0 provider will be used.

在我们的示例中,将使用SQL Server Native Client 11.0提供程序。

In the Server name combo box, select the SQL Server instance that contains the source data.

在“ 服务器名称”组合框中,选择包含源数据SQL Server实例。

如何使用SQL Server导入和导出向导将数据导入/导出到SQL Server

Note: If you are work with multiple servers or on a network, it is better to enter the name of the server instead to expand the combo box, because it may take a long time to list all available servers and it can cause the Not Responding state:

注意 :如果要使用多个服务器或在网络上,最好输入服务器名称而不是展开组合框,因为列出所有可用服务器可能会花费很长时间,并且可能会导致“无响应”州:

如何使用SQL Server导入和导出向导将数据导入/导出到SQL Server

Under the Authentication part, choose how to connect to the data source, by using Windows or SQL Server authentication.

在“ 身份验证”部分下,选择如何使用Windows或SQL Server身份验证连接到数据源。

In the Database combo box, select a database from which want to export data:

在“ 数据库”组合框中,选择要从中导出数据的数据库:

如何使用SQL Server导入和导出向导将数据导入/导出到SQL Server

When everything is set on the Choose a Data Source page, press the Next button to continue. The next page in the SQL Server Import and Export Wizard is the Choose a Destination page:

在“选择数据源”页面上设置完所有内容后,请按“ 下一步”按钮继续。 SQL Server导入和导出向导的下一页是“ 选择目标”页:

如何使用SQL Server导入和导出向导将数据导入/导出到SQL Server

On this page, the information about where the data will be placed and how to connect to the destination must be provided.

在此页面上,必须提供有关数据放置位置以及如何连接到目标的信息。

To specify destination from the Destination combo box, select the provider that will import data to the destination.

要从“ 目标”组合框中指定目标,请选择将数据导入到目标的提供程序。

A number of options that will be shown on this page depends of the selected provider in the Destination combo box.

此页面上将显示的许多选项取决于“ 目标”组合框中选择的提供程序。

For the purpose of this article, the Microsoft Excel provider will be selected in the Destination combo box for importing data to the Microsoft Excel file:

出于本文的目的,将在“目标”中选择Microsoft Excel提供程序 用于将数据导入到Microsoft Excel文件的组合框:

如何使用SQL Server导入和导出向导将数据导入/导出到SQL Server

From the name of the provider, it can be determined which destination the provider is intended for. For example, the Microsoft Access (Microsoft Access Database Engine) provider is intended to import data to Microsoft Access, the .Net Farmworker Data Provider for Oracle is for importing the Oracle database, etc.

根据提供者的名称,可以确定提供者要到达的目的地。 例如, Microsoft Access (Microsoft Access数据库引擎)提供程序旨在将数据导入到Microsoft Access, Oracle的.Net Farmworker数据提供程序用于导入Oracle数据库,等等。

The Destination combo box lists only the data providers that are installed on your machine. Also, if the 64-bit SQL Server Import and Export Wizard is used in the Destination combo box won’t be listed installed 32-bit providers.

目标”组合框仅列出计算机上安装的数据提供程序。 另外,如果在“ 目标”组合框中使用了64位SQL Server导入和导出向导,则不会列出已安装的32位提供程序。

As soon as the provider is chosen in the Destination combo box, additional options for settings will appear.

在“ 目标”组合框中选择提供商后,将显示其他设置选项。

如何使用SQL Server导入和导出向导将数据导入/导出到SQL Server

In the Excel file path box, type the destination to the Excel file, for example:

在“ Excel文件路径”框中,键入Excel文件的目标,例如:

  • For the destination on the local machine: C:\Users\Zivko\Desktop\ExportData.xlsx

    对于本地计算机上的目标:C:\ Users \ Zivko \ Desktop \ ExportData.xlsx
  • For the destination on the network: \\Example\Excel\ExportData.xlsx

    对于网络上的目标:\\ Example \ Excel \ ExportData.xlsx

Or use the Browse button on the Choose a Destination page to locate the Excel file:

或使用“ 选择目标”页面上的 浏览”按钮找到Excel文件:

如何使用SQL Server导入和导出向导将数据导入/导出到SQL Server

Using the Open dialog, other files rather than Excel can be selected, but when press the Next button on the Choose a Destination page, the following warning message will appear:

使用“打开”对话框,可以选择其他文件而不是Excel,但是在“ 选择目标”页面上按“下一步”按钮时,将出现以下警告消息:

“File path contains invalid Excel file. Please provide file with .xls, .xlsx, .xlsm, or .xlsb extension.”

“文件路径包含无效的Excel文件。 请提供扩展名为.xls,.xlsx,.xlsm或.xlsb的文件。”

如何使用SQL Server导入和导出向导将数据导入/导出到SQL Server

The SQL Server Import and Export Wizard does not support a password-protected Excel file. In case that password-protected Excel file is used, the similar warning message may appear:

SQL Server导入和导出向导不支持受密码保护的Excel文件 。 如果使用受密码保护的Excel文件 ,则可能会出现类似的警告消息:

“The operation could not be completed.
External table is not in the expected format. (Microsoft Access Database Engine)”

“操作无法完成。
外部表格的格式不正确。 (Microsoft Access数据库引擎)”

如何使用SQL Server导入和导出向导将数据导入/导出到SQL Server

Under the Excel version combo box, choose the version of Excel for the Excel file.

在“ Excel版本”组合框下,为Excel文件选择Excel的版本。

In some cases, an additional file must be installed in order to successfully connect to the Excel file, otherwise, the following warning message may appear:

在某些情况下,必须安装其他文件才能成功连接到Excel文件 ,否则,可能会出现以下警告消息:

“The operation could not be completed.
The ‘Microsoft.ACE.OLEDB.16.0’ provider is not registered on the local machine. (System.Data)”

“操作无法完成。
“ Microsoft.ACE.OLEDB.16.0”提供程序未在本地计算机上注册。 (系统数据)”

如何使用SQL Server导入和导出向导将数据导入/导出到SQL Server

The next page in the SQL Server Import and Export Wizard is the Specify Table Copy or Query page:

SQL Server导入和导出向导的下一页是“ 指定表副本或查询”页面:

如何使用SQL Server导入和导出向导将数据导入/导出到SQL Server

On this page, two radio buttons exist:

在此页面上,存在两个单选按钮:

The Copy data from one or more tables or views option is for copying all data from the existing tables or views in the source database.

从一个或多个表或视图复制数据”选项用于从源数据库中的现有表或视图复制所有数据。

The Write a query to specify the data to transfer option is for copying specific data from the source database by using a query.

编写查询以指定要传输的数据”选项用于通过使用查询从源数据库复制特定数据。

To copy more than one database or database objects that are not tables and views, use the Copy Database Wizard instead of the SQL Server Import and Export Wizard.

若要复制不是表和视图的多个数据库或数据库对象,请使用“ 复制数据库向导”而不是“ SQL Server导入和导出向导”。

Choose the Copy data from one or more tables or views or Write a query to specify the data to transfer radio button and click the Next button.

从一个或多个表或视图中选择“ 复制数据”,或选择“ 编写查询以指定要传输的数据”单选按钮,然后单击“ 下一步”按钮。

从一个或多个表或视图复制数据 (Copy data from one or more tables or views)

If the Copy data from one or more tables or views radio button is chosen, then, the next page in the SQL Server Import and Export Wizard will be the Select Source Tables and Views page:

如果选择了“从一个或多个表或视图复制数据”单选按钮,则SQL Server导入和导出向导中的下一页将是“ 选择源表和视图”页面:

如何使用SQL Server导入和导出向导将数据导入/导出到SQL Server

In the Tables and views grid under the Source column, all available views and tables from the AdventureWorks2014 database will be listed.

在“ 源”列下的“ 表和视图”网格中,将列出AdventureWorks2014数据库中所有可用的视图和表。

Use the check box next to the table/view to copy data from source to destination:

使用表/视图旁边的复选框将数据从源复制到目标:

如何使用SQL Server导入和导出向导将数据导入/导出到SQL Server

The name of the copied view/table in the Destination column can be changed by clicking on the name of the view/table:

通过单击视图/表的名称,可以更改“ 目标”列中复制的视图/表的名称:

如何使用SQL Server导入和导出向导将数据导入/导出到SQL Server

The name sets here will be used as the name of the worksheet in the Excel file:

此处设置的名称将用作Excel文件中工作表的名称:

如何使用SQL Server导入和导出向导将数据导入/导出到SQL Server

By clicking the Edit Mappings button, the Column Mappings dialog will appear:

通过单击“ 编辑映射”按钮,将出现“ 列映射”对话框:

如何使用SQL Server导入和导出向导将数据导入/导出到SQL Server

Here can be set additional options of how and which data will be exported.

可以在此处设置有关如何导出数据以及导出哪些数据的其他选项。

At the beginning of the Column Mappings dialog, under Source, the name of the source query, view, or table is shown. In Destination, the name of the destination view or table is shown:

在“ 列映射”对话框的开头,在“ 源”显示源查询,视图或表的名称。 在“ 目标”中,显示目标视图或表的名称:

如何使用SQL Server导入和导出向导将数据导入/导出到SQL Server

The Create destination table option, if the destination table does not exist, creates a new destination table (e.g. ProductTest).

如果目标表不存在,则创建目标表选项将创建一个新的目标表(例如ProductTest)。

When clicking the Edit SQL button, the Create Table SQL Statement dialog will appear:

单击“ 编辑SQL”按钮时,将出现“ 创建表SQL语句”对话框:

如何使用SQL Server导入和导出向导将数据导入/导出到SQL Server

This box automatically generates the CREATE TABLE statement that can be modified/customized, more about this can be found on the Create Table SQL Statement page.

此框将自动生成可修改/自定义的CREATE TABLE语句,有关更多信息,请参见“ 创建表SQL语句”页面。

The Create destination table radio button and Edit SQL button are disabled if the destination name already exists:

如果目标名称已经存在,则“ 创建目标表”单选按钮和“ 编辑SQL”按钮将被禁用:

如何使用SQL Server导入和导出向导将数据导入/导出到SQL Server

If the destination name exists the Delete rows in destination table and Append rows to destination table radio buttons are enabled:

如果目标名称存在,则启用“ 删除目标表中的 行”和“ 将行追加到目标表”单选按钮:

如何使用SQL Server导入和导出向导将数据导入/导出到SQL Server

If the Delete rows in destination table radio button is selected, this will clear all data from the existing table/files before importing the new data.

如果选中了“ 删除目标表中的行”单选按钮,则将在导入新数据之前清除现有表/文件中的所有数据。

If the Append rows to destination table radio button is selected, this will put the new data to the data that already exist to the destination table/file.

如果选中了“ 将行追加到目标表”单选按钮,这会将新数据放入目标表/文件已存在的数据中。

The Drop and re-create destination table checkbox is only enabled when the package that the SQL Server Import and Export Wizard creates is saved and then the package runes again.

仅当保存了SQL Server导入和导出向导创建的程序包,然后再次运行该程序包时,才启用“ 删除并重新创建目标表”复选框。

The Mappings section of the Column Mappings dialog shows the column of the data source and corresponding the columns in the destination:

“列映射”对话框的“ 映射”部分显示数据源的列以及目标中的列:

如何使用SQL Server导入和导出向导将数据导入/导出到SQL Server

The Source column lists all columns from the source column.

Source列列出了source列中的所有列。

The Destination column lists the name of the mapped destination column. In this column, the column that you don’t want to import into destination file can be excluded by selecting the <ignore> item from the combo box:

Destination列列出了映射的目标列的名称。 在此列中,可以通过从组合框中选择<ignore>项目来排除不想导入到目标文件中的列:

如何使用SQL Server导入和导出向导将数据导入/导出到SQL Server

The Type column shows the data type for the destination columns. The data type can be changed by selecting other type from the combo box:

类型列显示目标列的数据类型。 可以通过从组合框中选择其他类型来更改数据类型:

如何使用SQL Server导入和导出向导将数据导入/导出到SQL Server

In the Nullable column, it can be specified whether the destination column allowed a null value or not.

Nullable列中,可以指定目标列是否允许使用null值。

In the Size column, the size of the destination column can be specified:

在“ 大小”列中,可以指定目标列的大小:

如何使用SQL Server导入和导出向导将数据导入/导出到SQL Server

In the Precision column, the precision of the numeric data for the destination column can be specified, here can be set the number of the digits.

在“ 精度”列中,可以指定目标列的数字数据的精度,在此可以设置位数。

In the Scale column, the number of the decimal place for the numeric destination column can be set:

在“ 比例”列中,可以设置数字目标列的小数位数:

如何使用SQL Server导入和导出向导将数据导入/导出到SQL Server

To preview data that will be copied to the destination, under the Select Source Tables and Views page, click the Preview button. This will open the Preview Data dialog box:

要预览将复制到目标的数据,请在“ 选择源表和视图”页面下,单击“ 预览”按钮。 这将打开“ 预览数据”对话框:

如何使用SQL Server导入和导出向导将数据导入/导出到SQL Server

The Preview Data dialog box displays up to 200 rows of data from the data source.

“预览数据”对话框最多显示来自数据源的200行数据。

编写查询以指定要传输的数据 (Write a query to specify the data to transfer)

If the Write a query to specify the data to transfer radio button is chosen on the Specify Table Copy or Query page of the SQL Server Import and Export Wizard, then the Provide a Source Query dialog box will appear:

如果在SQL Server导入和导出向导的“ 指定表副本或查询”页面上选中了“ 编写查询以指定要传输的数据的查询”单选按钮,则将出现“ 提供源查询”对话框:

如何使用SQL Server导入和导出向导将数据导入/导出到SQL Server

In this dialog, a query from the file can be written, pasted or loaded by clicking the Browse button, which selects source data to copy to the destination.

在此对话框中,可以通过单击“ 浏览”按钮来写入,粘贴或加载来自文件的查询,该按钮选择源数据以复制到目标。

In the SQL statement editor, put the desired query and press the Parse button to check if the SQL statement is valid:

SQL语句编辑器中,放入所需的查询,然后按“ 解析”按钮以检查SQL语句是否有效:

如何使用SQL Server导入和导出向导将数据导入/导出到SQL Server

Now, when press the Next button, the Select Source Tables and Views page will appear; in the Tables and view grid the [Query] item that represents the query that is written in the Provide a Source Query page will be shown:

现在,当按下“ 下一步”按钮时,将显示“ 选择源表和视图”页面; 在“表和视图”网格中,将显示“查询”项,该项代表在“ 提供源查询”页面中编写的查询

如何使用SQL Server导入和导出向导将数据导入/导出到SQL Server

The next page of the SQL Server Import and Export Wizard is the Review Data Type Mapping page:

SQL Server导入和导出向导的下一页是“ 查看数据类型映射”页面:

如何使用SQL Server导入和导出向导将数据导入/导出到SQL Server

This page shows information about data type conversation that will be performed to make the source data compatible with the destination.

此页面显示有关数据类型对话的信息,将执行这些信息以使源数据与目标数据兼容。

If a problem with data type conversation exists, the warning icon next to the data source in the Table list will appear and, in the Data type mapping list, the warning icons will appear next to the source columns which indicates that this conversation may cause a loss of data:

如果存在数据类型对话的问题,则“ 表”列表中数据源旁边的警告图标将出现,并且在“ 数据类型映射”列表中,警告图标将出现在“源”列旁边,这表明此对话可能会导致数据丢失:

如何使用SQL Server导入和导出向导将数据导入/导出到SQL Server

To view additional information about an individual column, double click on that column and the Column Conversion Details dialog will appear:

要查看有关单个列的其他信息,请双击该列,然后将出现“ 列转换详细信息”对话框:

如何使用SQL Server导入和导出向导将数据导入/导出到SQL Server

On this page, source and destination information will be shown as well as the data type of the source and destination column, conversion steps etc.

在此页面上,将显示源和目标信息以及源和目标列的数据类型,转换步骤等。

On the Review Data Type Mapping page, the data type cannot be changed, but it can be returned to the Select Source Tables and Views page by clicking the Back button. On the Select Source Tables and Views page, click the Edit Mappings button to open the Column Mappings dialog box and, from there, change the data type.

在“ 查看数据类型映射”页面上,无法更改数据类型,但是可以通过单击“上一步”按钮将其返回到“ 选择源表和视图”页面。 在“ 选择源表和视图”页面上,单击“ 编辑 映射”按钮以打开“ 列映射”对话框,然后从那里更改数据类型。

After the data source and destination are specified and configured, click the Next button. The SQL Server Import and Export Wizard shows the Save and Run Package page:

指定并配置数据源和目标后,单击“ 下一步”按钮。 SQL Server导入和导出向导显示“ 保存并运行包” 页面

如何使用SQL Server导入和导出向导将数据导入/导出到SQL Server

By default, the Run immediately option for the import and export data immediately is checked. To save the settings as the SSIS package, the Save SSIS Package check box needs to be checked.

默认情况下, 立即 运行的进口和出口数据选项将立即进行检查。 要将设置保存为SSIS包,需要选中“ 保存SSIS包”复选框

If the Save SSIS Package check box is checked, additional page will be shown when clicking the Next button:

如果选中“ 保存SSIS包”复选框,则单击“ 下一步”按钮时将显示其他页面:

如何使用SQL Server导入和导出向导将数据导入/导出到SQL Server

On the Save SSIS Package page, additional options for saving the SSIS package can be specified. More about these options can be found on the Save SSIS Package page.

在“保存SSIS包”页面上,可以指定用于保存SSIS包的其他选项。 有关这些选项的更多信息,请参见“ 保存SSIS包”页面。

The next page of the SQL Server Import and Export Wizard is the Complete the Wizard page:

SQL Server导入和导出向导下一页是“ 完成向导”页面:

如何使用SQL Server导入和导出向导将数据导入/导出到SQL Server

On this page, all choices that are made in this wizard will be shown. This page will show the following information:

在此页面上,将显示此向导中所做的所有选择。 该页面将显示以下信息:

  • Data source location

    数据源位置
  • Destination location

    目的地位置
  • The data that to be copied

    要复制的数据
  • Whether will be the package run immediately or saved etc.

    包将立即运行还是保存等。

To finalize the exporting process, click the Finish button. The SQL Server Import and Export Wizard will show the Performing Operation page:

要完成导出过程,请单击“ 完成”按钮。 SQL Server导入和导出向导将显示“ 执行操作”页面:

如何使用SQL Server导入和导出向导将数据导入/导出到SQL Server

This page shows the state of the data has been successfully exported or some errors occurred during exporting data.

此页面显示数据状态已成功导出,或在导出数据期间发生了一些错误。

The Action column shows the steps of the operation.

操作”列显示了操作步骤。

The Status column shows if the step finished successfully or with an error.

状态”列显示该步骤是成功完成还是出现错误。

The Message shows the informational or error messages for each step.

消息显示每个步骤的信息或错误消息。

To get more information about the step click on the displayed item:

要获取有关该步骤的更多信息,请单击显示的项目:

如何使用SQL Server导入和导出向导将数据导入/导出到SQL Server

To view a report of the results, save the report, copy report or send the report vie e-mail, click the Report button and from the menu, choose a desired option:

要查看结果报告,保存报告,复制报告或通过电子邮件发送报告,请单击“报告”按钮,然后从菜单中选择所需的选项:

如何使用SQL Server导入和导出向导将数据导入/导出到SQL Server

To verify that the SQL Server Import and Export Wizard successfully has exported data to the Excel file, find and open that Excel file, in our case that is the SQL Data.xlsx file:

若要验证SQL Server导入和导出向导已成功将数据导出到Excel文件,请找到并打开该Excel文件,在本例中为SQL Data.xlsx文件:

如何使用SQL Server导入和导出向导将数据导入/导出到SQL Server

翻译自: https://www.sqlshack.com/importexport-data-sql-server-using-sql-server-import-export-wizard/