hi,
What is a synonym in Sql Server? Why would you want to create a synonym?
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Satyapriya NayakPosted Apr 30, 2012, 10:32 PM
What is SYNONYM?
SYNONYM is a single-part name that can replace a two, three or four-part name in many SQL statements. Using SYNONYMS in RDBMS cuts down on typing.
SYNONYMs can be created for the following objects:
Let us assume we have two databases namely RainbowResearch and RiverResearch as shown below.
Let us assume that we have the following schemas and objects on the databases RainbowResearch and RiverResearch.
Now let us query the tables from all the schemas from both of the databases.
You will see the following results. [Refer Fig 1.0]
Fig 1.0
Assume that I want to query all the above tables, in both the databases, using a Single part name. In order to achieve this we are going to create SYNONYMS, as shown below.
Now let us query, using the Single part name in both databases, as shown below.
You will see the following results. [Refer Fig 1.1]
Fig 1.1
The same SYNONYM can be created for stored procedures as well:
Now let us execute the stored procedures using the one part name, as shown below.
You will see the following results. [Refer Fig 1.2]
Please refer the below link
http://www.databasejournal.com/features/mssql/article.php/3635426/SYNONYM-in-SQL-Server-2005.htm
http://blog.sqlauthority.com/2008/01/07/sql-server-2005-introduction-and-explanation-to-synonym-helpful-t-sql-feature-for-developer/
Thanks
Maziyar NazaryanPosted Apr 30, 2012, 2:43 PM