Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Update temp tables

Author  Topic 

jrobin747
Starting Member

48 Posts

Posted - 2013-08-19 : 16:37:39
I don't know how to update a temp table with another temp table

for example I have #tempdashboard that has info in it.
I also have #tempappscount of which I want to insert the info inside it into #tempdashboard

I believe the column in #tempdashboad is
DailyAppsIn INT,

I did a query that gave me the number of daily apps created. I was told to create #tempappscount and my query to dump into #tempappsaccount. Then dump the info from #tempappsaccount into #tempdashboard.

Clueless but still trying to learn. Thanks

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2013-08-19 : 16:46:34
The basci pattern for inserting from one temp table to another should be:
INSERT #TempTable1
(
Column1,
Column2,
...
)
SELECT
Column1,
Column2,
..
FROM
#TempTable2
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-08-20 : 05:57:19
how to update a temp table with another temp table

would be something like

UPDATE d
SET DailyAppsIn =a.appcountfield
FROM #tempappscount a
INNER JOIN #tempdashboard d
ON d.relatedcol = a.relatedcol


relatedcol is column(s) by which two tables are related

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
   

- Advertisement -