What is the use of Synonym keyword in Sql Server, define and give example? SQL Server Interview Question

SQL Server Interview Question:What is the use of Synonym key word in Sql Server, define and give example?
Ans: A synonym is an alternative name for objects such as tables, views, sequences, stored procedures, and other database objects. You generally use synonyms when you are granting access to an object from another schema and you don't want the users to have to worry about knowing which schema owns the object.

Example: We can create synonyms for MgmtTrainging table which exist under JProCo database. like this
CREATE SYNONYM Classes FOR JProCo.dbo.MgmtTraining

Now you can use 
it is same as 

SELECT * FROM JProCo.dbo.MgmtTraining

Click here for more than 300 Sql server Interview questions



Contact Form