Nickname/synonym concept in SQL Server?

  • Does anyone know of an equivalent in SQL Server 2000 for what Oracle calls a synonym and DB2 calls a nickname? Essentially I'm looking for the ability to create another name that I can use to reference an object in a remote database. For example, let's say that I have 2 SQL Server 2000 databases: one named ADMIN and one named CERT. In the CERT database, I want to create a synonym/nickname for a table that exists in the ADMIN database. This allows me to reference the remote object by the nickname in my code instead of specifying the remote table name in the full-fledged format linked_server_name.catalog.schema.object_name.

    I could probably do this with a view, but am curious if this type of thing could be done more like it is in Oracle/DB2.

    Thanks for your help,

    Robin

  • There isn't anything like this in SQL Server.

    Steve Jones

    sjones@sqlservercentral.com

    http://www.sqlservercentral.com/columnists/sjones

  • OK, Thanks for the information Steve

  • I think what you might be looking for is a view. Although not a true nickname/synonym it should work. I would create a view that references your ADMIN table in your CERT database. This view can have the name of the ADMIN table. Then in you query you can reference the view just like it was a table in CERT, but in fact it will retrieve data from your ADMIN table.

    I'm guessing this is what you want. Does this work for you.

    Gregory Larsen, DBA

    If you looking for SQL Server Examples check out my website at http://www.geocities.com/sqlserverexamples

    Gregory A. Larsen, MVP

  • Greg-

    Yes, I had seen in the documentation that a view would probably get me what I needed - but I wondered if there was an equivalent concept to synonym/nickname. I am new to working with SQL Server (don't even have an environment to experiment in yet!), so I just wanted to check.

    Thanks for your reply...

    Robin

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply