Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Create a table from a query

Author  Topic 

yazasi
Starting Member

11 Posts

Posted - 2008-11-16 : 15:22:43
Hello all,

Can someone please provide a simple script on how to create a table from a query using two servers: Server 1 and Server 2, Table 1 from Server 1 and Table 2 from Server 2 where Customer_ID in Table 1 = Customer_ID in Table 2. I need to return three columns from Table 1 and three columns from Table 2. Name the new created table Customers_Table.

Thanks.

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2008-11-16 : 17:43:02
This is only an approach for the minimum given info:

select
s1.columnx
s2.columny
into Customers_Table
from
server_1.database_1.dbo.table1 s1
join server_2.database_2.dbo.table2 s2
on s2.Customer_ID = s1.Customer_ID


Greetings
Webfred


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page
   

- Advertisement -