kalls
kalls

Reputation: 2865

Getting SQL Server values from a view on a different server

I have access to a View called (vw_table) on Server1. I want to get the data from this view (few million records) into a table on server2.

I tried

SELECT * INTO ##TempTable
FROM VW_Table

This gets the data in to ##TempTable.

Now how can I move it to a different server (server2) and to a different database?

I want Table2 in Server2 to have the data from VW_table.

I appreciate your help.

Upvotes: 0

Views: 62

Answers (2)

Diego
Diego

Reputation: 36156

you cant direct access another server like this. You have to options to solve your problem:

  • Configure a linked server on server1 to access server2 then you do: select * from mylinkedserver..table
  • Create a SSIS package to read data from server1 and insert on server2

Upvotes: 1

zimdanen
zimdanen

Reputation: 5626

Like Lemak said, you can't pass temporary tables around like this. You either need to have a Linked Server and copy the data directly into the table, or you need to export the data and import it into the table using SSIS.

Upvotes: 0

Related Questions