Quantcast
Channel: Forum SQL Server Database Engine
Viewing all articles
Browse latest Browse all 15889

Powershell to import csv file

$
0
0

Hello all,

Running sql 2008 sp1

New to PowerShell. Can someone please check the syntax and tell me if something doesn't look right.

Trying to load a csv file into a table

The csv file is comma delimited and contains double quotes around values that have a comma in them.

        $Server = "MyServer"
        $Database = "MyDatabase"
        $Table = "MyTable"
        $ShareUNCPath = "\\MyShareUNCpath\MyTestfile.csv"
        $DataImport = Import-Csv -Path $ShareUNCPath
        $DataTable = Out-DataTable -$DataImport
        Write-DataTable -ServerInstance $Server -Database $Database -TableName $Table -Data $DataTable

Thanks

gv


Sword


Viewing all articles
Browse latest Browse all 15889

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>