Click here to Skip to main content
16,018,938 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have 2 SQL servers hosting different data for different software programs.
I'm trying to write a query that will extract the data from 1 SQL server/database, then add it to a another SQL server/database/table. Is this possible to do? Error messages are "Database 'tomsqlvision' does not exist. I'm connected (logged in) to both of them in MSSMS. I'm new to SQL and just learning it so any help is appreciated. Thanks

What I have tried:

SELECT R.REM_PID AS [PID],
R.REM_PIN AS [GIS ID],
R.REM_OWN_NAME AS [Owner Name],
O.ROW_PID AS [PID1],
O.MAD_MAIL_ADDR1 AS [Street],
O.MAD_MAIL_CITY AS [City],
O.MAD_MAIL_STATE AS [State]
FROM [tomsqlvision]VISION.dbo.REAL_PROP.REALMAST R
INNER JOIN [tomsqlvision]VISION.dbo.REAL_PROP.VW_RPT_OWNERMAILADDRESSDETAILSVIEW O
ON R.REM_PID = O.ROW_PID
Posted
Updated 4-May-23 18:36pm
Comments
Richard Deeming 5-May-23 3:49am    
NB: dbo.REAL_PROP.REALMAST and dbo.REAL_PROP.VW_RPT_OWNERMAILADDRESSDETAILSVIEW are not valid table/view names.

If you've really put a . in the middle of the object names, then you need to quote the names properly: dbo.[REAL_PROP.REALMAST] and dbo.[REAL_PROP.VW_RPT_OWNERMAILADDRESSDETAILSVIEW]

1 solution

You can learn linked server here

Create one linked server named tomsqlvision,
and use it something like this
select * FROM [tomsqlvision].VISION.dbo.REAL_PROP.REALMAST
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900