Zum Inhalt springen

SQL-Import aus CSV mit Powershell

$SQLserver = 'server-instanz'
$Path_to_exports = 'D:'Temp'SQL_Exports'
$files = Get-ChildItem -Pfad $Path_to_exports
 foreach ($file in $files)
     ((Get-Content -path $file. FullName -Raw) -ersetzen ''','') | Set-Content -Pfad $file. Fullname 
     $DestDB = (Get-Item $file. FullName). BaseName -split '-'
     Import-DbaCsv -Pfad $file -SqlInstance $SQLserver -Database $DestD[0]B -Table $DestD[1]B 
 }