I have hit this issue a couple times and I wanted to share my solution with everyone.
I was getting this error in Visual Studio on a stored procedure that referred to a linked server even after I created the linked server.
TSD4001: Could not find server 'XXXX' in sys.servers. Verify that the correct server name was specified. If necessary, execute the stored procedure sp_addlinkedserver to add the server to sys.servers. (SQL error = 7202)
To fix this, do the following:
- In the stored procedure change the name of the linked server to another name that does not exist (i.e. add a 1 to the end) and save.
- Change the name back to the original name and save.
- The error should be gone.
Happy Coding!