Link to home
Start Free TrialLog in
Avatar of running32
running32

asked on

Error on linked server query

update upload set strmatch = 1
where (name in (select BC-DENTRIX.dbo.ddb_pat_base.lastname from BC-DENTRIX.dbo.ddb_pat_base))
and (dob in (select BC-DENTRIX.dbo.ddb_pat_base.birthdate from BC-DENTRIX.dbo.ddb_pat_base))
and (lname in (select BC-DENTRIX.dbo.ddb_pat_base.firstname from BC-DENTRIX.dbo.ddb_pat_base))

I am trying to run the above query on a linked server but I am getting the message below.  I would be greatful for any help on how to resolve this.  Thank you
Server: Msg 170, Level 15, State 1, Line 2
Line 2: Incorrect syntax near '-'.
Server: Msg 170, Level 15, State 1, Line 3
Line 3: Incorrect syntax near '-'.
Server: Msg 170, Level 15, State 1, Line 4
Line 4: Incorrect syntax near '-'.

Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

update upload set strmatch = 1
where (name in (select [BC-DENTRIX].dbo.ddb_pat_base.lastname from [BC-DENTRIX].dbo.ddb_pat_base))
and (dob in (select [BC-DENTRIX].dbo.ddb_pat_base.birthdate from [BC-DENTRIX].dbo.ddb_pat_base))
and (lname in (select [BC-DENTRIX].dbo.ddb_pat_base.firstname from [BC-DENTRIX].dbo.ddb_pat_base))
or more efficient coding:

update upload
 set strmatch = 1
from upload u
join [BC-DENTRIX].dbo.ddb_pat_base x
  on x.lastname = u.name
 and x.birthdatre = u.dob
 and x.firstname = u.lname
Avatar of running32
running32

ASKER

It gives me the error Invalid object name 'BC-DENTRIX.dbo.ddb_pat_base'. but I see the linked server BC-Dentrix in my linked server list and can see the tables through enterprise manager.

thanks
ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
WONDERFUL..... THANK YOU