Advertisement
Guest User

Untitled

a guest
Oct 24th, 2014
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. $Path = "****"
  2. $server = '****'
  3. $database = 'Emails'
  4. $table = 'Exchange_Export'
  5. $FileArray = Get-ChildItem $Path
  6. $i = 0
  7.  
  8. Do{
  9. $File = $fileArray[$i]
  10. $Files = $path+"\"+$File
  11. $query = "BULK INSERT " + $table+" FROM '"+$Files+"' WITH (KEEPIDENTITY, FIELDTERMINATOR = ',', ROWTERMINATOR = '\n');"
  12. Invoke-Sqlcmd -Query $query -ServerInstance $server -Database $database
  13. $i
  14. $i++
  15. }While ($i -le $FileArray.count)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement