As stated in the previous post, a synonym in databases is an alternative name or alias for a table, view, sequence, or other schema items. They are mostly used to simplify access for users to database objects owned by other users. In this article, we will see how to reference the Synonym in Dynamic SQL.
Let’s create a Synonym first.
CREATE SYNONYM Trxns
Now, let’s use it in dynamic SQL.
EXECUTE (‘SELECT TrxnID FROM Trxns’);
Hope you find this article helpful.