Friday, May 24, 2013

How to get data in temp table and then copy it to another table in SQL Server

How to copy data from temp table in SQL server 2008?


with MovieSlice as          
(          
      select moviestock.moviesuffix,count(moviesongs.id_song) as songsCount from moviestock
inner join moviesongs on moviestock.moviesuffix = moviesongs.moviesuffix
group by moviestock.moviesuffix    
)    

UPDATE
    MovieStock
SET
    MovieStock.songsCount = MovieSlice.songsCount
FROM
    MovieStock
INNER JOIN
    MovieSlice
ON
    MovieSlice.moviesuffix = MovieStock.moviesuffix

No comments:

Post a Comment