MSACCESS CODE转换为SQL

时间:2017-07-13 07:56:42

标签: sql-server ms-access-2010

您好我想请求您的帮助我有一个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

我真的需要帮助,谢谢你

1 个答案:

答案 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_PINContractNetwork相等? SAP_PINContractNetworkqry_HR_temp_Consultant_Data_DuplicateNetwork_EachValue中的组合是唯一的?