SQL Server - query between 2 different servers (could not be bound) -


this question has answer here:

my aim

to find field 1 servers database table in other servers database table

the problem

using below event, unable use where/and table wants join, when implement join in, states "could not bound" when there field common name

below query using tailored make generic

select        customerdatabase.dbo.oldcustomertable.customerid,       customerdatabase.dbo.oldcustomertable.firstname,       customerdatabase.dbo.oldcustomertable.surname,       customerdatabase.dbo.oldcustomertable.dob        customerdatabase.dbo.oldcustomertable  inner join        [remoteservername\customerdatabasenew].customerdatabasev2.dbo.newcustomertable on        customerdatabase.dbo.oldcustomertable.customerid =        [remoteservername\customerdatabasenew].customerdatabasev2.dbo.newcustomertable.customerid        customerdatabase.dbo.oldcustomertable.dob = [remoteservername\customerdatabasenew].customerdatabasev2.dbo.newcustomertable.dob 

i have added 1 line in new table, example:

  • firstname : john
  • surname : smith
  • dob : 1990-01-20 (20th january 1990)

and using information query above should return values have dob: 1990-01-20

tables:

customerdatabase (old)

  create table oldcustomertable (customerid int identity (1,1) not null,   firstname varchar(50),   surname varchar(50),   dob date)    alter table oldcustomertable add constraint customerid_pk primary key (customerid) 

customerdatabasenew (new)

  create table customertablev2 (customerid int identity (1,1) not null,   firstname varchar(50),   surname varchar(50),   dob date)    alter table customertablev2 add constraint customerid_pk primary key (customerid) 

i have linked both databases using sp_addlinkedserver , can run query such as:

select * [remoteservername\customerdatabasenew].customerdatabasev2.dbo.newcustomertable

any pointers helpful of how solve issue, , thank help? know customerid different in new table matter? or possible join on dob?

edit: tried , without aliases , need aliases work, hope helps.

try adding alias tables in join, possible duplicate of this question

select        customerdatabase.dbo.oldcustomertable.customerid,       customerdatabase.dbo.oldcustomertable.firstname,       customerdatabase.dbo.oldcustomertable.surname,       customerdatabase.dbo.oldcustomertable.dob        customerdatabase.dbo.oldcustomertable old  inner join        [remoteservername\customerdatabasenew].customerdatabasev2.dbo.newcustomertable new on        old.customerid =        new.customerid        old.dob = new.dob 

Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -