SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Update temp tables
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

jrobin747
Starting Member

USA
48 Posts

Posted - 08/19/2013 :  16:37:39  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

4354 Posts

Posted - 08/19/2013 :  16:46:34  Show Profile  Reply with Quote
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

India
52249 Posts

Posted - 08/20/2013 :  05:57:19  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.04 seconds. Powered By: Snitz Forums 2000