Sunday, May 5, 2019

Get List of Files and Insert to SQL Server Table

Get-ChildItem -Path C:\ETL\EXPORT_FILES |
Select-Object Name, FullName, Extension, CreationTime, Length |
Write-SqlTableData -ServerInstance localhost -DatabaseName ETL -SchemaName import -TableName ImportFileList -Force

Initially loclhost was working but then it stopped with failed to connect message; changed to actual SQL Server instance name
and that worked:


Get-ChildItem -Path C:\ETL\EXPORT_FILES |
Select-Object Name, FullName, Extension, CreationTime, Length |
Write-SqlTableData -ServerInstance "DESKTOP-U8PAEJC" -DatabaseName "DEV_STAGING" -SchemaName "import" -TableName "ImportFileList" -Force

No comments:

Post a Comment