High on SQL!!!

Aug 17
### Data import using PowerShell

#let’s clean up the Test.Person table first

Import-Module SQLPS -DisableNameChecking

Truncate-Table $instanceName $dbName

$server = “localhost”

$table = “AdventureWorks2014.Test.Person”

$importfile = “C:\Temp\Exports\Person.Person.csv”

#command to import from csv

$cmdimport = “bcp $($table) in `”$($importfile)`” -S$server -T -c -t `”|`” -r `”\n`” ”

#run the import command

Invoke-Expression $cmdimport

#delay 1 sec, give server some time to import records

#sleep helps us avoid race conditions

Start-Sleep -s 2

Get-PersonCount $instanceName $dbName



There are no comments for this post.