0

I have linked one server [10.66.78.62\SQLSERVER2017] with mine sql server Test connection: Successful

While running the query It's unable to identify the database.

Error :Invalid object name 'EWS.dbo.EWS_Final'.

I have tried attaching server name before database. ....

No success.

        SELECT sum(case when DATEDIFF(DAY, TAB.[DPS Created Time]) 
    FROM [EWS].[dbo].[EWS_Final] with (nolock)
        OUTER APPLY (select top 1 d.[DPS #],d.[Service Request Number],d.[DPS Created Time], d.[DPS Type], d.[Labor Status], d.[Parts Status], d.[Activity Status] , d.[Call Type]
from [EWS].[dbo].[EWS_DispatchDetails] d 
where CAST([DPS #] as bigint) !=0  and [EWS].[dbo].[EWS_Final].[Service Request Number] = d.[Service Request Number] 
order by  d.[DPS Created Time] desc) as tab
    where [Employee Subgroup Name] = 'OOP'
    and [Region] = 'NORTHAM'
    --and [Bus Rpt Team Name] NOT IN ('ARG','OOP_ARG','Not Assigned','GGN_OOP_SSR','BRA_EMEA_OOP' )
    and  [Location] IN ('Delhi, India')
Rahul
  • 903
  • 1
  • 10
  • 27
  • My Apology, Couldn't paste the entire code. – usama.nomani Aug 08 '19 at 12:18
  • You need to specify the server as well when referencing the table on the linked server. https://stackoverflow.com/questions/4091960/sql-server-linked-server-example-query – Isaac Aug 08 '19 at 12:26
  • Possible duplicate of [SQL Server : get access to linked server through linked server](https://stackoverflow.com/questions/35766404/sql-server-get-access-to-linked-server-through-linked-server) – Rahul Aug 08 '19 at 12:27
  • Aplology, as I was not able to post the entire code. As when I am using .... on join query it states cant bound, however when I run it directly on server there is no error
    – usama.nomani Aug 08 '19 at 13:03

1 Answers1

2

You can use the Syntax given below for Linked Server Query:

select * 
FROM [Linked servername].[DatabaseName].[Schema Name].[TableName]
Rahul
  • 903
  • 1
  • 10
  • 27
hardikpatel
  • 300
  • 1
  • 5
  • In a normal query it does work but when I am using it on join operation started giving me error related to can't bound. Same code run ob server it self. – usama.nomani Aug 08 '19 at 13:18