0
我有下面的power-shell代碼,試圖將一個excel文件導入DB1。將文件導入到SQL Server 2012時發生錯誤
$dir = "\\server\folder\"
$latest = Get-ChildItem -Path $dir | Where-Object {$_.name -like "*Notes*"} | Sort-Object LastWriteTime -Descending | Select-Object -First 1
Write-Output "The latest file is: $latest"
Write-SqlTableData -ServerInstance "instance1" -DatabaseName "DB1" -SchemaName dbo -TableName Table1 -InputData $latest -Force
上午陷入錯誤,當我運行此代碼,見下圖:
Write-SqlTableData : A mapping between .Net type 'System.IO.DirectoryInfo' and SQL type for column 'Directory' was not found. Consider removing the column with that type and repeat the operation
我用Google搜索這個錯誤,似乎沒有得到任何幫助。任何人都可以幫助我嗎?