如何将Excel文件导入SQL Server数据库?
我正在尝试这样做:
INSERT INTO temptable SELECT * FROM OPENROWSET( 'Microsoft.Jet.OLEDB.4.0',
'Excel 8.0;Database=\\team4\files\Update_66.xls','SELECT * FROM [Sheet1$]')
然后我遇到了这个错误:
无法创建OLE DB提供程序的实例" Microsoft.Jet.OLEDB.4.0" 对于链接服务器"(null)"
有没有办法在powershell中做到这一点?
请帮帮我。
在阅读下面的Rigerta Demiri的代码之后,这是我的代码:
$dir = "\\server\files\"
$latest = Get-ChildItem -Path $dir | Sort-Object LastWriteTime -Descending | Where-Object {$_.name -like "xyzfile"} | Select-Object -First 1
$SQLServerConnection = "Data Source=rock;Integrated Security=true;Initial Catalog=team;"
$bulkCopy = new-object ("Data.SqlClient.SqlBulkCopy") $SQLServerConnection
$bulkCopy.DestinationTableName = "temptable"
$bulkCopy.WriteToServer($latest)
此代码给出了以下错误消息:
Multiple ambiguous overloads found for "WriteToServer" and the argument count: "1".