Move SQL query results to another table

Tags:
SQL Query
SQL Server
I have this query:
SELECT a.*
FROM devices_staging a
INNER JOIN
(
SELECT ComputerName, MAX(SystemSync) max_date
FROM devices_staging
GROUP BY ComputerName
) b ON a.ComputerName = b.ComputerName AND
a.SystemSync = b.max_date
And the results I get are correct. How do I move these results to another table?
1

Answer Wiki

Thanks. We'll let you know when a new response is added.

Create a table on server using the scripts generated from the table on the source server and run the following t-sql script


INSERT INTO dbo.YourTableNameHere SELECT * FROM [SourceServer].[SourceDatabase].dbo.YourTableNameHere 

Discuss This Question: 1  Reply

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
  • ToddN2000
    If this is just for using as a work table, you can wrap it in another SELECT. Otherwise follow the answer above and use the INSERT INTO method.
    134,780 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: