2
People, I need to create a temporary table with 2 fields (codProduct and codBarra), and with these temporary table records, I need to update to my main table.
How do update with select in the temporary table?
2
People, I need to create a temporary table with 2 fields (codProduct and codBarra), and with these temporary table records, I need to update to my main table.
How do update with select in the temporary table?
2
It’s no secret:
update tabelaprincipal
set codBarra = temp.codBarra
from #tabelatemporaria temp
where tabelaprincipal.codProduto = temp.codProduto
0
Raimundo,
To perform an "UPDATE" statement with a temporary table, you will need to link the information between the table that should be updated (I believe that in your case the ideal is to use the "Product").
Below is a T-SQL script for you to adapt to your need:
UPDATE TB_PRODUTO SET
codBarra = TMP.codBarra
FROM #TB_AUXILIAR AS TMP
INNER JOIN TB_PRODUTO AS UPD
ON UPD.codProduto = TMP.codProduto;
GO
For more information see:
Browser other questions tagged sql-server
You are not signed in. Login or sign up in order to post.
Example of
update from
: http://answall.com/a/65182/14584. The difference between a temporary table and a regular table is only the prefix#
(temporary local) or##
(global temp) in table name. Example:#tabela_temporaria_local
. Try to build your commands and edit your question with the specific problems encountered.– Caffé