我有这段代码,它用 Excel 表中的值更新表中的几列。我尝试使用 sqlserver 模块来实现这一点,但我想知道有没有办法使用 DBATOOLS 模块来执行操作?
for ($row8 = 9; $row8 -lt 40; $row8++) {
if ([string]::IsNullOrEmpty($ws3.Cells.Item($row8, 3).Value2)){break} else {
$sqlCmd.CommandText = "UPDATE $Table7 SET STCW_Cert_Held = $ws3.Cells.Item($row8, 18).Value2,
ISPS = $ws3.Cells.Item($row8, 19).Value2,
Marine_Medical_Exp = $ws3.Cells.Item($row8, 20).Value2,
Petronas_Medical_Exp = $ws3.Cells.Item($row8, 21).Value2,
OSP_Exp = $ws3.Cells.Item($row8, 22).Value2,
Shell_SafetyPassport_Exp = $ws3.Cells.Item($row8, 23).Value2,
Boseit_Exp = $ws3.Cells.Item($row8, 24).Value2,
BT_STCW_Exp = $ws3.Cells.Item($row8, 25).Value2,
Rigging_Slinging_Exp = $ws3.Cells.Item($row8, 26).Value2,
FoodHandling_Exp = $ws3.Cells.Item($row8, 27).Value2,
H2S_Exp = $ws3.Cells.Item($row8, 28).Value2,
COC_Exp = $ws3.Cells.Item($row8, 29).Value2,
COR_Exp = $ws3.Cells.Item($row8, 30).Value2,
Seaman_Card_Exp = [string] $ws3.Cells.Item($row8, 31).Value2,
Passport_Exp = [string] $ws3.Cells.Item($row8, 32).Value2 WHERE PasportNumber = $ws3.Cells.Item($row8, 3).Value2"
}
}