Skip to content
This repository was archived by the owner on Jun 29, 2019. It is now read-only.

Commit 7e1a0ba

Browse files
committed
address when the existing table names do not have _randomnumber
1 parent 748dc3c commit 7e1a0ba

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

Misc/SQLDW/SQLDW_Data_Import.ps1

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,18 @@ function WriteConfFile(){
9797

9898
function Generate_new_names($OldString, $New_RandomNumber,$Delimiter){
9999
$OldRN = $OldString.Split($Delimiter)[-1]
100-
$NewString = $OldString -replace $OldRN, $New_RandomNumber
100+
try{
101+
$OldRN_Int = $OldRN -as [int]
102+
if ($OldRN_Int -ge 100 -and $OldRN -le 999){
103+
$NewString = $OldString -replace $OldRN, $New_RandomNumber
104+
} else{
105+
$NewString = $OldString + '_' + $New_RandomNumber
106+
Write-Host "Old table name $OldString does not end with random number between 100 and 999. The new table name with random number is $NewString." -ForegroundColor "Yellow"
107+
}
108+
} catch{
109+
$NewString = $OldString + '_' + $New_RandomNumber
110+
Write-Host "Old table name $OldString does not end with random number between 100 and 999. The new table name with random number is $NewString." -ForegroundColor "Yellow"
111+
}
101112
return $NewString
102113
}
103114

0 commit comments

Comments
 (0)