How do I create and use a Synonym for a table in SQL Server 2005?
June 14, 2008
To create a synonym, run the following SQL code:
USE AdventureWorks;
GO
CREATE SYNONYM MyLocation
FOR AdventureWorks.Production.Location;
GO
To use the synonym, run the following SQL code:
USE AdventureWorks;
GO
SELECT TOP 5 * FROM MyLocation;
GO
To drop the synonym, run the following SQL code:
USE AdventureWorks;
GO
DROP SYNONYM MyLocation;
GO
Entry Filed under: SQL Scripts. Tags: 2005, abstraction, CREATE SYNONYM, server, sql, synonym.
Trackback this post | Subscribe to the comments via RSS Feed