将数据从Excel传输到SQL Server

Jas*_*son 7 sql-server export

我有一个Excel电子表格,其中包含我需要放入SQL Server数据库的所有数据.我是相当新的ASP.NET,从来没有必须从Excel导出到SQL Server.

我的Excel电子表格看起来像这样

贸易标题 - > ArtID - >商业名称 - > AdStyleCode - >地址 - >郊区

在SQL Server中,我创建了一个名为"Listings"的表,它采用这种格式

intListingID - > intCategoryID - > BusinessName - ArtID - > intAdCode - >地址 - >郊区

从Excel导出数据然后将其导入SQLServer 2005的最佳方法是什么.

谢谢...

Bin*_*ony 4

您可以使用 SSIS 轻松完成此操作,您可以参考这两个链接以获取完整的详细信息。

  1. 链接1
  2. 链接2

[编辑]

如果您有 Express,那么您可以尝试以下命令来设置链接服务器并获取数据

EXEC sp_addlinkedserver ExcelData,'Jet 4.0','Microsoft.Jet.OLEDB.4.0','C:\MyData.xls', NULL, 'Excel 5.0;'
GO
Run Code Online (Sandbox Code Playgroud)

然后您可以将数据选择到表中

INSERT INTO Listings ...
SELECT column1 AS intListingID, <put all columns here> FROM ExcelData...Data
GO
Run Code Online (Sandbox Code Playgroud)

对于其他选项,请检查此链接