bcp escape special character password

This commit is contained in:
Eqbal Zaffar 2017-06-19 13:59:46 -07:00
Родитель f463bc6666
Коммит 13cb831342
2 изменённых файлов: 4 добавлений и 5 удалений

Просмотреть файл

@ -139,9 +139,9 @@ if ($uninterrupted -eq 'y' -or $uninterrupted -eq 'Y')
Write-Host -ForeGroundColor 'magenta'(" Populate SQL table: {0}... from {1}" -f $dataFile, $destination)
$tableName = $DBName + ".dbo." + $dataFile + $table_suffix
$tableSchema = $dataFilePath + $dataFile + $table_suffix + ".xml"
bcp $tableName format nul -c -x -f $tableSchema -U $username -S $ServerName -P "$password" -t ','
bcp $tableName format nul -c -x -f $tableSchema -U $username -S $ServerName -P "{$password}" -t ','
Write-Host -ForeGroundColor 'magenta'(" Loading {0} to SQL table..." -f $dataFile)
bcp $tableName in $destination -t ',' -S $ServerName -f $tableSchema -F 2 -C "RAW" -b 100000 -U $username -P "$password" -e $error_file
bcp $tableName in $destination -t ',' -S $ServerName -f $tableSchema -F 2 -C "RAW" -b 100000 -U $username -P "{$password}" -e $error_file
Write-Host -ForeGroundColor 'magenta'(" Done...Loading {0} to SQL table {1}..." -f $dataFile, $tableName)
}
@ -228,9 +228,9 @@ if ($ans -eq 'y' -or $ans -eq 'Y')
Write-Host -ForeGroundColor 'magenta'(" Populate SQL table: {0} from {1}..." -f $dataFile, $destination)
$tableName = $DBName + ".dbo." + $dataFile + $table_suffix
$tableSchema = $dataFilePath + $dataFile + $table_suffix + ".xml"
bcp $tableName format nul -c -x -f $tableSchema -U $username -S $ServerName -P "$password" -t ','
bcp $tableName format nul -c -x -f $tableSchema -U $username -S $ServerName -P "{$password}" -t ','
Write-Host -ForeGroundColor 'magenta'(" Loading {0} to SQL table..." -f $dataFile)
bcp $tableName in $destination -t ',' -S $ServerName -f $tableSchema -F 2 -C "RAW" -b 100000 -U $username -P "$password" -e $error_file
bcp $tableName in $destination -t ',' -S $ServerName -f $tableSchema -F 2 -C "RAW" -b 100000 -U $username -P "{$password}" -e $error_file
Write-Host -ForeGroundColor 'magenta'(" Done...Loading {0} to SQL table {1}..." -f $dataFile, $tableName)
}
}

Просмотреть файл

@ -103,7 +103,6 @@ select *,
(select top 1 remain_balance from payments_info_$(datasize) p2 where DATEDIFF(month, p2.payment_date,p1.payment_date) = 4 AND p1.loanId = p2.loanId) remain_balance_4,
(select top 1 remain_balance from payments_info_$(datasize) p2 where DATEDIFF(month, p2.payment_date,p1.payment_date) = 5 AND p1.loanId = p2.loanId) remain_balance_5
from payments_info_$(datasize) p1 ) AS t inner join loan_info_$(datasize) l ON t.loanId = l.loanId inner join member_info_$(datasize) m ON l.memberId = m.memberId
where t.charge_off IS NOT NULL
and payment_date > '2017-02-12';
go