这是生产代码,因此我无法选择检查错误 SqlProfile跟踪显示更新已尝试7次。
$query = "Select pkey, field1 from Table1 with (NOLOCK) where etc ....;";
$unitsrs = sqlsrv_query($conn,$query) or die('sqlsrv error: ' . print_r( sqlsrv_errors()) );
while($unitsrow = sqlsrv_fetch_array($unitsrs)) {
$pkey = $unitsrow['pkey'];
$field1 = $unitsrow['field1'];
$newvalue = 0;
...
$update = "Update Table1 Set Field1 = $newvalue where pkey = '$pkey';";
sqlsrv_query($conn, $update);
}
答案 0 :(得分:0)
从更新查询中删除分号
$update = "Update Table1 Set Field1 = $newvalue where pkey = '$pkey'";