0

I have found out a lot of messages from stack overflow but it is too much information to me , and I didn't see any clear code ,I wish I can use like as below URLs with easy way

Querying data by joining two tables in two database on different servers

Selecting data from two different servers in SQL Server

PS: sorry for all , maybe my English isn't very well ,so that I cannot understand or know , hopefully someone can give me a very simple code

Community
  • 1
  • 1
  • 1
    Hi @Wee Wei what kind of code do you want to use ?? – Willie Cheng Jan 12 '16 at 03:28
  • 1
    Hi I just need to sample code on SQL Server Management Studio ( I mean pure T-SQL script ) –  Jan 12 '16 at 03:31
  • 1
    Tip: It's helpful to tag database questions with both the appropriate software (MySQL, Oracle, DB2, ...) and version, e.g. `sql-server-2014`. Differences in syntax and features often affect the answers. – HABO Jan 12 '16 at 04:14
  • But you have simple sample code in those links – paparazzo Jan 12 '16 at 08:06

1 Answers1

0

This sample is very easy , hopefully it is you want

1.Data Source <=Server ip or ServerName
2.Initial Catalog <= DB Name
3.User ID <= Account ID
4.Password <= Account PWD
5.[*****].[dbo].[awards] <= which table you want to find out

SELECT *
FROM OPENDATASOURCE('SQLNCLI',
    'Data Source=10.***.***.***;Initial Catalog=B2C**;User ID=****;Password="****"')
    .[*****].[dbo].[awards]

PS: more detail you can see
https://msdn.microsoft.com/zh-tw/library/ms179856(v=sql.120).aspx

or Querying data by joining two tables in two database on different servers
or Selecting data from two different servers in SQL Server

it will be gave you more detail ways or methods

Community
  • 1
  • 1
Willie Cheng
  • 7,679
  • 13
  • 55
  • 68