Sql server create synonym statement syntax to create a synonym you use the create synonym statement as follows. A synonym is nothing more than an alternate name that you can create for a database object.
You can create synonyms for tables temp tables views stored procedures and functions.
How to get list of synonyms in sql server. Personally i d be fine with a list of all synonyms however answering his question does get one step closer to the end need. I can retrieve the columns of the synonym using below query in sql server. This will give you the name of the synonym and the name of the object the synonym is created for.
I have created synonyms in my local server for a table which is located on the remote server. Select db id parsename base object name 3 as dbid object id base object name as objid base object name from sys synonyms. Base object name or anything else that will show the exact text of the synonym this query does more of less what i want it to do but it works on a single database only.
Provides an alternative name for another database object referred to as the base object that can exist on a local or remote server. Check if a database has synonyms to the objects in another database if exists select base object name from sys synonyms where base object name like. In sql server a synonym is an alias or alternative name for a database object such as a table view stored procedure user defined function and sequence.
I need to fetch the columns of the synonym. A synonym provides you with many benefits if you use it properly. Synonym used create synonym dbo test for remoteserver name database name schema name object name.
Original question can some one please help me out to get the list of synonyms were used in the stored procedure example. You can simple create a synonym to point to an object and then reference that synonym in all of your queries. Sql server synonyms for nested objects in the different databases this query will find synonyms for nested objects in another database.
Sql server azure sql database azure synapse analytics parallel data warehouse a synonym is a database object that serves the following purposes. Sql server all supported versions azure sql database azure sql managed instance azure synapse analytics parallel data warehouse contains a row for each synonym object that is sys objects type sn. The sys synonyms catalog view can be used to get a list of synonyms you have in a given database.