Since you are open to powershell, I have used this method. It's important that the last think in each file is your LF/CR. If it could be missing then you'd have to put a check in there for that.
#Remove the last bit of data from the end of the file, which is a LF, so BULK INSERT doesn't break
$fileDirectory = "E:\dir\subdirectory"
foreach($file in Get-ChildItem $fileDirectory)
{
$filePath = $fileDirectory + "\" + $file
$stream = [IO.File]::OpenWrite($filePath)
$stream.SetLength($stream.Length - 2)
$stream.Close()
$stream.Dispose()
}
I use this on a pretty large daily dataset and it's stupid fast, a second or two. Original idea credited to Joey via this answer.
Since you are open to powershell, I have used this method. It's important that the last think in each file is your
LF/CR
. If it could be missing then you'd have to put a check in there for that.Single File
Multiple Files in a directory
I use this on a pretty large daily dataset and it's stupid fast, a second or two. Original idea credited to Joey via this answer.
FROM THE OP