Synonym Usage

I am trying to use Synonyms to refer to Linked Servers the SQL Select statements work just fine with the Synonyms but SQL Prompt consistently underlines the Synonym usage  stating Invalid Object Name.  Is there something I am doing wrong to can I have SQL Prompt not shows this as an issue?
Tagged:

Answers

  • Hi there,

    Thank you for reaching out and I apologize that you are running into issues with SQL Prompt.

    From this page: https://documentation.red-gate.com/sp/sql-refactoring/refactoring-an-object-or-batch/finding-invalid-objects

    Objects are listed as invalid by SQL Prompt if they:

    • can't be compiled
    • can be compiled, but can't be executed
      For example, a stored procedure that references an object that no longer exists in the database is listed as invalid.
      WARNING: synonyms with not existing reference are not supported.
    Thank you!
    David Kim
    Product Support Engineer


  • sqlmtcsqlmtc Posts: 4 New member
    David,  I did search the forum and had seen this posting from what I believe was 3 years ago.  Can you please explain this "WARNING: synonyms with not existing reference are not supported.", as it is not clear to me what that statement means?
  • Hi there,

    The "WARNING: synonyms with not existing reference are not supported." means that if a synonym is not anchored to a base reference point, SQL Prompt will list it as invalid.

    Kind Regards,
    David Kim
    Product Support Engineer

  • sqlmtcsqlmtc Posts: 4 New member
    Can you define "base reference point"?  Maybe you could provide an example.
  • Hi there,

    Let's say that you are trying to pull the Employee table of Adventure Works, located on a server named Server1 into Server2. So you create a synonym named Emp.Table to reference the Employee table in Server1. However, if you were to drop the Employee table from Server1, Emp.Table would no longer have a base reference point to go off of and SQL Prompt would label it as an "Invalid Object Name"

    Kind Regards,
    David Kim
    Product Support Engineer

  • sqlmtcsqlmtc Posts: 4 New member
    What you are saying makes sense in the fact that your synonym reference was dropped and would indeed be an invalid object.   My example works just fine as the reference exists and in my opinion is valid.  Can you provide an example where I can use a linked server with a synonym that works and doesn't say it is invalid?
Sign In or Register to comment.