0

I am writing a system that reads from a remote server and read/write to a local server. I am at the point where I now have to query data from both the remote server and my local server together (for example: if the remote server had the user's address and my local server has the user's phone number, I want to query both databases and get results that contain both the user's address and phone number in one return).

I recently learned about linked server and wanted to update my code to use it, but I am having trouble getting started.

I am using SQL Server Management and have both my LocalDB and LinkedServerDB on it (see reference screenshot).

But when I try to reference the LinkedServerDB in my LocalDB stored procedure, it doesn't seem to recognize the linked server. I googled a few examples and it seems like people were able to reference it in this manner:

[ServerName].[Database].[dbo].[TableName]

But it doesn't seem to recognize the syntax when I write it in that manner. Is there a settings I need to toggle to make this work? Is what I'm trying to do possible?

Screenshot of SQL Server Management Objects

Any assistance or guidance is greatly appreciated.

2
  • 2
    It should work fine, but sometimes ssms doesn't refresh its intellesense so it looks like objects are missing. Just run and see what happens Commented Nov 24, 2024 at 13:18
  • 1
    CTRL+SHIFT+R to refresh Intellisense. Commented Nov 24, 2024 at 14:05

1 Answer 1

0

Well.... I feel like an idiot. Read the above comments (thank you Siggemannen and Charlieface). I tried refreshing / restarting SSMS but it still marks the linked server as an error (red squiggly line).

I just created the stored procedure, ran a test, and it works. Although...even when I go to modify the stored procedure, it still does marks the linked server as an error/typo... Not sure if that is something I'm doing wrong, but it seems to work now. My OCD may get the best of me by the end of my project, but I'll power through it somehow.

Thank you again

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.