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.
| Author |
Topic |
|
dr223
Constraint Violating Yak Guru
444 Posts |
Posted - 2011-11-10 : 05:54:48
|
Hi, I have the following query which works fine when both databases are in the same server. However, what I want to do is connect to a different server to access the data from GPRD-RCT database..the query is a view in a VMD database, which contains the dbo.TblAuto_coll table. SELECT DISTINCT dbo.TblAuto_coll.Prac_noFROM dbo.TblAuto_coll INNER JOIN [GPRD-RCT].dbo.Practice ON dbo.TblAuto_coll.Prac_no = [GPRD-RCT].dbo.Practice.PracticeCode GPRD-RCT database stored in a different server - server: 166.2.3.4username: testpassword: password12any ideas how I can formulate this? |
|
|
RickD
Slow But Sure Yak Herding Master
3608 Posts |
Posted - 2011-11-10 : 06:19:43
|
| you need to set up a linked server. Look up sp_addlinkedserver and sp_addlinkedserverlogin |
 |
|
|
eralper
Yak Posting Veteran
66 Posts |
Posted - 2011-11-10 : 06:59:42
|
| Hello dr223,The best way is to create a linked serverBut another alternative is using OpenRowSet command Here "[url]http://www.kodyaz.com/articles/encrypted-views-openrowset-connect-remote-sql-server.aspx[/url]" you can find a sample sql script with openrowset.-------------Eralperhttp://www.kodyaz.com |
 |
|
|
|
|
|