troubleshooting Question

Updating table from another table using memory tables

Avatar of Mortarello
MortarelloFlag for United Kingdom of Great Britain and Northern Ireland asked on
Microsoft SQL ServerMicrosoft SQL Server 2008
3 Comments1 Solution377 ViewsLast Modified:
Hello Guys,

I'm trying to uptade a memory table from another memory tabble like the code bellow.
but I'm geting the error saying (Must declare the scalar variable "@source".)

Is there any way how to do this using memory table ?


 declare @source table (id int, name varchar(30), surname varchar(30))
 declare @copy table (id int, name varchar(30), surname varchar(30))
 insert into @source (id,name,surname) values(1,'michel','mortarello')
 insert into @source (id,name,surname) values(2,'michel','mortarello')

 insert into @copy (id,name) values(1,'michel')
 insert into @copy (id,name) values(2,'michel')

 update @copy
      set surname = @source.surname
      from @copy inner join @source on =
 select * from @copy

Many thanks guys
Database Consultant
Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros