Search code examples
sqlsql-serverssms

Msg 7202, Level 11, State 2, Line 1 Could not find server 'acct' in sys.servers


Would you know what could be the code error on query with my tables and server database connection, I normally list my query in the following format and today it provides me with the same continued error and only this query is displaying this type of error. My tables are referencing the correct database due to the reason that this is the only database that hods these tables. My query code listed below, maybe its missing something.

SELECT  Distinct
'CA' AS 'Server'     
 
, DATENAME(month, res.Move_in_Date) [MonthName]
, DATEPART(day, res.Move_in_Date) [Day]
, DATENAME(WEEKDAY, res.Move_in_Date) [Weekday]

, res.Move_in_Date
, res.Move_out_Date
, ge.Entity_Number
, bld.Building_Name
, addr.Address2
, addr.City
, addr.State
, addr.Zip_Code
, bld.Building_ID
, unts.Unit_Number
, res.First_Name
, res.Last_Name
, ge.Active AS GL_Entities_Active
, bld.Building_Active

FROM            
acct.cam_ca.dbo.residents AS res

INNER JOIN
acct.cam_ca.dbo.units AS unts
ON res.Unit_ID = unts.Unit_ID 

INNER JOIN
acct.cam_ca.dbo.addresses AS addr

INNER JOIN
acct.cam_ca.dbo.gl_entities AS ge
ON addr.Address_ID = ge.Address_ID 

INNER JOIN
acct.cam_ca.dbo.buildings AS bld
ON ge.GL_Entity_ID = bld.GL_Entity_ID ON unts.Building_ID = bld.Building_ID


WHERE 
ge.Active = 1
AND ge.Entity_Number = 1
AND bld.Building_Active = 1

AND res.Move_in_Date BETWEEN '20200101 00:00:00.000 AM' AND '20200707 11:59:59 PM'


ORDER BY 
ent.Entity_Number
, res.Move_in_Date

Solution

  • As can be read from the error message the server mentioned in the query is not available in metadata view sys.servers.There are two possibilities,

    1. The server "acct" is not available.

    2. The server "acct" is defined but could have a different name defined.

    Troubleshoot by running queries Run the query below to list all available servers ,

    select name,data_source from sys.servers
    

    Try to identify the name corresponding to the data_source and use that name instead of acct for the server in your query. If you are unable to identify a relevant entry, contact DBA to provide the details of the server.