7/31/2010
LifeCycle Solutions - Home ( the software development blog )
 

<August 2006>
SunMonTueWedThuFriSat
303112345
6789101112
13141516171819
20212223242526
272829303112
3456789

Subscribe to this feed:

RSS 2.0 | Atom 1.0 |CDF






Wednesday, August 23, 2006

Referencing fully-qualified object names in SQL Server can be tedious, particularly if you're not using an editor with Intellisense (a la ApexSQL Edit).  If the object you're working with is on a linked server, it becomes even more of a burden to get the full name correct, since it can have 4 parts:  server.database.owner.object

Fortunately, SQL Server 2005 comes to the rescue with a new database feature called synonyms.  Synonyms can be used as an alias to a fully-qualified object name, so the table "ProductionServer.ProductionDatabase.dbo.Parts" can be referenced in your queries as simply "Parts" by issuing the following statement:

CREATE SYNONYM Parts for ProductionServer.ProductionDatabase.dbo.Parts

SELECT * FROM Parts

This can also be done visually in SQL Server Management Studio.
Posted by Brian Parks

© 2006 LifeCycle Solutions, LLC | All Rights Reserved