1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > 如何使用导入平面文件向导将平面文件导入SQL Server数据库

如何使用导入平面文件向导将平面文件导入SQL Server数据库

时间:2024-05-25 17:59:37

相关推荐

如何使用导入平面文件向导将平面文件导入SQL Server数据库

Import Flat File wizard is a new feature implemented in SQL Server Management Studio (SSMS) v17.3 for importing a .csv or a .txt file into a SQL Server database.

导入平面文件向导是SQL Server Management Studio(SSMS)v17.3中实现的一项新功能,用于将.csv或.txt文件导入SQL Server数据库。

The latest SSMS version can be found on this link

在此链接上可以找到最新的SSMS版本

To invoke the Import Flat File wizard, go toObject Explorer, select a database you want to use to import data from a .csv or .txt file, right click and from the context menu, choose theImport Flat Fileoption:

要调用导入平面文件向导,请转到对象资源管理器,选择要用于从.csv或.txt文件导入数据的数据库,右键单击并从上下文菜单中选择“导入平面文件”选项:

This will open theImport Flat FileIntroductionpage providing an overview of the features and showing what needs to be specified in order to successfully import data from a flat file to a SQL Server database.

这将打开“导入平面文件简介”页面,其中概述了功能并显示了需要指定哪些内容才能成功将数据从平面文件导入SQL Server数据库。

If you don’t wish to see this page next time the Import Flat File feature is invoked, just check theDo not show this page again. After that press theNextbutton to proceed with importing a flat file:

如果您不希望下次调用“导入平面文件”功能时看到此页面,只需选中“不再显示此页面”。 之后,按“下一步”按钮继续导入平面文件:

The next page of the Import Flat File wizard is theSpecify Input Filepage. On this page, we need to set up the location of a flat file which will be used for importing into a SQL Server database. Also, we need to add the name of the table which will be created into a SQL Server database to hold the imported data from a flat file:

导入平面文件向导的下一页是“指定输入文件”页面。 在此页面上,我们需要设置平面文件的位置,该文​​件将用于导入到SQL Server数据库中。 另外,我们需要添加将在SQL Server数据库中创建的表的名称,以保存从平面文件导入的数据:

To pick a location of a flat file, click theBrowsebutton. By default, the Import Flat File wizard is set to search for the .csv and .txt files. The Import Flat File wizard allows to pick another file format then .csv and .txt. For example, a .xlsx file format can be selected:

要选择平面文件的位置,请单击“浏览”按钮。 默认情况下,“导入平面文件”向导设置为搜索.csv和.txt文件。 导入平面文件向导允许选择其他文件格式,然后是.csv和.txt。 例如,可以选择.xlsx文件格式:

But on the next page of the Import Flat File wizard, the following error message will appear when another file format then .csv or .txt is used:

但是,在“导入平面文件”向导的下一页上,使用其他文件格式(然后是.csv或.txt)时,将出现以下错误消息:

“An error occurred while running learn on the input file.

Additional information:

Cannot find patterns in the input file. (Microsoft.SqlServer.Prose.Import)”

“在输入文件上运行学习时发生错误。

附加信息:

在输入文件中找不到模式。(Microsoft.SqlServer.Prose.Import)”

Let’s go back to theSpecify Input Filepage and, this time, choose the correct file format (e.g. ImportData.csv):

让我们回到“指定输入文件”页面,这次,选择正确的文件格式(例如ImportData.csv):

By default, the name of the table in the New table name box will be the name of the imported .csv/.txt file (ImportData).

默认情况下,“新表名称”框中的表名称将是导入的.csv / .txt文件(ImportData)的名称。

The name of the table in which will be imported data can be changed and set whatever is liked as long as the SQL Server table and column naming conventions are followed.

只要遵循SQL Server表和列命名约定 ,就可以更改要在其中导入数据的表的名称并设置所需的值。

The name of a new table should be unique and must not exist in the destination database, otherwise the following message will appear when the Next button is pressed:

新表的名称应该是唯一的,并且在目标数据库中不能存在,否则,当按下“下一步”按钮时,将出现以下消息:

“Provided table name already exists.”

“提供的表名已经存在。”

After the unique name for the table is set, press theNextbutton to continue. The next page of the Import Flat File wizard isPreview Data:

设置表的唯一名称后,按“下一步”按钮继续。 导入平面文件向导的下一页是预览数据

This page generates a preview of data that are located in the ImportData.csv file and how they will look like when are generated into a table. The Preview Data page generates max up to first 50 rows.

此页面将生成ImportData.csv文件中数据的预览,以及在表中生成后的外观。 “预览数据”页面最多可生成前50行。

If you are satisfied with the preview, click theNextbutton to proceed:

如果您对预览感到满意,请单击下一步按钮继续:

On theModify Columnspage wizard analyze the data located in the .csv or .txt file and suggest what it believes that is correct for the column name and data type. The names of the columns, data types, primary key for the table, etc. can be modified/changed:

在“修改列”页面向导上,分析位于.csv或.txt文件中的数据,并提出对列名称和数据类型正确的建议。 可以修改/更改列的名称,数据类型,表的主键等:

Once the settings on the Modify Column page are done, click theNextbutton. TheSummarypage will appear:

完成“修改列”页面上的设置后,单击“下一步”按钮。 将显示“摘要”页面:

This page shows the names of SQL Server, database and the name of the table where will data from the imported .csv file be stored.

此页面显示了SQL Server的名称,数据库以及将存储来自导入的.csv文件的数据的表的名称。

Click theFinishbutton to import data formImpotData.csv file to the ImportData SQL Server table.

单击“完成”按钮将数据formImpotData.csv文件导入到ImportData SQL Server表中。

The last page of the Import Flat File wizard is theResultspage. This page indicates whether the importing data from the flat file to a SQL Server table was successful or with errors:

导入平面文件向导的最后一页是结果页面。 该页面指示从平面文件到SQL Server表的数据导入成功还是有错误:

Now, when check the AdwnetureWorks database, under the Tables folder, the ImportData table will appear:

现在,当检查AdwnetureWorks数据库时,在Tables文件夹下,将显示ImportData表:

When importing data from the flat file to SQL Server database, make sure that you have adequate permissions, otherwise one of the following error message will appear:

将数据从平面文件导入SQL Server数据库时,请确保您具有足够的权限,否则将出现以下错误消息之一:

“Error creating table. (Microsoft.SqlServer.Import.Wizard)

Error creating table. (Microsoft.SqlServer.Prose.Import)

CREATE TABLE permission denied in database ‘AdventureWorks’. (Microsoft SQL Server, Error: 262)”

“创建表时出错。(Microsoft.SqlServer.Import.Wizard)

创建表时出错。(Microsoft.SqlServer.Prose.Import)

CREATE TABLE权限在数据库'AdventureWorks'中被拒绝。(Microsoft SQL Server,错误:262)”

“An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)

The server principal “Zivko” is not able to access the database “AdventureWorks” under the current security context. (Microsoft SQL Server, Error: 916)”

“执行Transact-SQL语句或批处理时发生异常。(Microsoft.SqlServer.ConnectionInfo)

服务器主体“ Zivko”在当前安全上下文下无法访问数据库“ AdventureWorks”。(Microsoft SQL Server,错误:916)”

“Error creating table. (Microsoft.SqlServer.Import.Wizard)

Error creating table. (Microsoft.SqlServer.Prose.Import)

The specified schema name “dbo” either does not exist or you do not have permission to use it. (Microsoft SQL Server, Error: 2760)”

“创建表时出错。(Microsoft.SqlServer.Import.Wizard)

创建表时出错。(Microsoft.SqlServer.Prose.Import)

指定的架构名称“ dbo”不存在,或者您没有使用它的权限。(Microsoft SQL Server,错误:2760)”

More about necessary permissions in order to use the Import Flat File wizard successfully can be found on this page

可以在此页面上找到有关成功使用“导入平面文件”向导的必要权限的更多信息。

翻译自: /import-flat-file-sql-server-database-using-import-flat-file-wizard/

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。