您好我想请求您的帮助我有一个MSACCESS代码,我想将其转换为SQL(SSMS),请参阅下面的代码。
Private Sub updateDuplicateNetwork()
Dim rstTemp As DAO.Recordset
Dim rst As DAO.Recordset
Dim strPIN As String
Dim strContract As String
Dim strNetwork As String
Set rstTemp = CurrentDb.OpenRecordset("qry_HR_temp_Consultant_Data_DuplicateNetwork_EachValue")
Set rst = CurrentDb.OpenRecordset("tbl_HR_Contract_Detail")
If Not rstTemp.EOF Then
rstTemp.MoveFirst
Do While Not rstTemp.EOF
If rstTemp!strNetwork <> strNetwork Or rstTemp!strNetwork <> strNetwork Or rstTemp!strNetwork <> strNetwork Then
strPIN = rstTemp!strPIN
strContract = rstTemp!strContract
strNetwork = rstTemp!strNetwork
rst.FindFirst ("[SAP_PIN] = '" & strPIN & "' AND [Contract] = '" & strContract & "' AND [Network] = '" & strNetwork & "'")
If Not rst.NoMatch Then
rst.Edit
rst!Allocated_Hrs = rstTemp!F38
rst.Update
End If
Else
rst.FindNext ("[SAP_PIN] = '" & strPIN & "' AND [Contract] = '" & strContract & "' AND [Network] = '" & strNetwork & "'")
If Not rst.NoMatch Then
rst.Edit
rst!Allocated_Hrs = rstTemp!F38
rst.Update
End If
End If
rstTemp.MoveNext
Loop
End If
Set rst = Nothing
Set rstTemp = Nothing
End Sub
我真的需要帮助,谢谢你
答案 0 :(得分:0)
这是你在做什么?
UPDATE qry_HR_temp_Consultant_Data_DuplicateNetwork_EachValue
INNER JOIN tbl_HR_Contract_Detail ON
qry_HR_temp_Consultant_Data_DuplicateNetwork_EachValue.SAP_PIN = tbl_HR_Contract_Detail.SAP_PIN
AND qry_HR_temp_Consultant_Data_DuplicateNetwork_EachValue.Contract = tbl_HR_Contract_Detail.Contract
AND qry_HR_temp_Consultant_Data_DuplicateNetwork_EachValue.Network = tbl_HR_Contract_Detail.Network
SET tbl_HR_Contract_Detail.Allocated_Hrs = qry_HR_temp_Consultant_Data_DuplicateNetwork_EachValue.F38;
您将Allocated_Hrs
设置为F38
,其中SAP_PIN
,Contract
和Network
相等?
SAP_PIN
,Contract
和Network
在qry_HR_temp_Consultant_Data_DuplicateNetwork_EachValue
中的组合是唯一的?