mercredi 28 janvier 2015

Trigger AFTER INSERT on tables with different collumns


I'm making a Trigger that works after an insert.


this is what i have:



create trigger trgInsereQuestao
on tblquestaoOpcao
after insert
as begin
set nocount on;
insert into CSIPSA.dbo.tblQuestaoOpcao

select


from inserted ins
join CSIPSA.dbo.tblQuestaoOpcao qo on qo.nrquestao = ins.NrQuestao
end


Yes, almost nothing.


The problem here is:


i need to copy data from PSACati.dbo.tblQuestaoOpcao to CSIPSA.dbo.tblQuestaoOpcao, but the collumns are different.


PSACATI.dbo.tblquestaoOpcao collumns:



1. idOpcao
2. NrQuestao
3. OrdemOpcao
4. Opcao
5. DescOpcao
6. NrQuestaoDest
7. CodStatus
8. Confirma
9. FlagRU
10. FlagSempre
11. Condicao
12. CodCampo
13. Valor
14. FlagRodizioOpcao
15. descOpcaoWeb
16. descOpcaoResumida
17. tooltip


CSIPSA.dbo.tblQuestaoOpcao collumns:



1. NRQUESTAO
2. ORDEMOPCAO
3. OPCAO
4. DESCOPCAO
5. DESCOPCAOLA
6. DESCOPCAORES
7. DESCOPCAORESLA
8. NRQUESTAODEST
9. NRQUESTAODESTLA
10. CODSTATUS
11. CONFIRMA
12. TROCARESP
13. RespostaDepara


so. What should i use inside the SELECT?


Thanks you very much friends.


Edit: There are collumns with null values ( it doesnt have anything to copy )





Aucun commentaire:

Enregistrer un commentaire