I have 2 tables, Tblservicedesk and Tblservicedesk_temp


  • CodServiceDesk
  • ID_Solicitacao
  • Solicitante
  • Departamento
  • Tecnico
  • Grupo
  • Status
  • Prioridade
  • Data_Abertura_Chamado
  • Data_Vencimento_Chamado
  • Data_Conclusao_Chamado
  • Nota
  • Comentario_Atendimento
  • data_criacao_registro
  • FlagEmailNota
  • FlagEmailSLA
  • FlagEmailFechado
  • data_resolved

I need to update the Tblservicedesk, with values of these 3 columns (FlagEmailNota, FlagEmailSLA, FlagEmailFechado ) from the Tblservicedesk_temp table.

All of this 3 columns is NULL in Tblservicedesk, and we have values in some columns in Tblservicedesk_temp.

I need to use ID_SOLICITAÇÃO as PK.

  • i'm trying to create a query with insert and joins, but with no success.
    – Racer SQL
    Feb 11, 2015 at 10:18
  • Insert into Tblservicedesk ( FlagEmailNota, FlagEmailSLA, FlagEmailFechado ) from Tblservicedesk_temp where ...
    – Racer SQL
    Feb 11, 2015 at 10:20
  • 1
    Do you want to INSERT new records or UPDATE existing records? Your question says update, your query says insert... Feb 11, 2015 at 10:32

2 Answers 2


Assuming both Tblservicedesk & Tblservicedesk_temp having same columns. You can write update statement to update the three columns (FlagEmailNota, FlagEmailSLA, FlagEmailFechado ).

   tsd.FlagEmailNota = tsdt.FlagEmailNota , 
   tsd.FlagEmailSLA = tsdt.FlagEmailSLA, 
   tsd.FlagEmailFechado = tsdt.FlagEmailFechado
   Tblservicedesk AS tsd
  Tblservicedesk_temp AS tsdt ON tsd.ID_SOLICITAÇÃO = tsdt.ID_SOLICITAÇÃO 

Since I don't have enough reputation to comment hence i'm posting this as an answer, if this is not what you are looking for please let me know.

  • Thank you very much brother. I'm not good in programming. it was really helpful...please, don't go alone, take this rep points with you
    – Racer SQL
    Feb 11, 2015 at 11:28
SET sd.FlagEmailNota = sdt.FlagEmailNota,
sd.FlagEmailSLA = sdt.FlagEmailSLA,
sd.FlagEmailFechado = sdt.FlagEmailFechado
FROM dbo.Tblservicedesk AS sd INNER JOIN dbo.Tblservicedesk_temp AS sdt ON sd.ID_Solicitacao = sdt.ID_Solicitacao

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.