November 26, 2008 at 1:52 pm
Comments posted to this topic are about the item Creating a Synonym for a Table - SQL School Video
Brian Knight
Free SQL Server Training Webinars
January 20, 2009 at 4:55 am
You described well the "how to" aspect of synonyms, but what I fail to grasp its the usefulness. Why would I want to create a synonym? What advantage is gained? By your example, I even have to type an extra keystroke ("1" or "2") when referring to the "Contact" table.
Thanks,
Arthur
Arthur Fuller
cell: 647-710-1314
Only two businesses refer to their clients as users: drug-dealing and software development.
-- Arthur Fuller
January 20, 2009 at 7:06 am
The usefulness of synonyms has do to with changing database object locations/names without changing application code. For instance if your application is coded to read from the Orders table and for some reason you have to point it at a copy of the Orders table on a different server you can create a synonym rather than changing your application code...or you can just change your app code. 🙂
January 20, 2009 at 8:13 am
I really wish you could use synonyms for databases on remote servers. We use SQL Client Aliases to keep from having to change code going from development , to QA, to Production. The only problem is that those are set on a server level. With clusters, that's one more thing to manage.
It would be nice to use synonyms to abstract the database call instead of having to resort to Client Aliases and Linked Servers.
January 20, 2009 at 5:15 pm
ChrisMoix (1/20/2009)
I really wish you could use synonyms for databases on remote servers. We use SQL Client Aliases to keep from having to change code going from development , to QA, to Production. The only problem is that those are set on a server level. With clusters, that's one more thing to manage.It would be nice to use synonyms to abstract the database call instead of having to resort to Client Aliases and Linked Servers.
Not sure what you are referencing here, but you can easily create a synonym that accesses an object through a linked server.
Create the linked server, then in the local database create the synonym as:
CREATE SYNONYM MySchema.Object FOR linkedserver.remotedb.schema.object;
Now, when your code is moved from DEV to QA to PROD - it doesn't have to change. The synonyms on each system are setup to access the appropriate server and objects.
Jeffrey Williams
“We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”
― Charles R. Swindoll
How to post questions to get better answers faster
Managing Transaction Logs
January 21, 2009 at 1:39 am
fuller.artful (1/20/2009)
You described well the "how to" aspect of synonyms, but what I fail to grasp its the usefulness. Why would I want to create a synonym? What advantage is gained? By your example, I even have to type an extra keystroke ("1" or "2") when referring to the "Contact" table.Thanks,
Arthur
This link can answer your query:
January 21, 2009 at 6:27 am
Not sure what you are referencing here, but you can easily create a synonym that accesses an object through a linked server.
Create the linked server, then in the local database create the synonym as:
CREATE SYNONYM MySchema.Object FOR linkedserver.remotedb.schema.object;
I basically want a synonym on a whole database, not an object at a time. Currently I have to use a combination of a Client Network Alias and a Linked Server to accomplish this;
For example - Server 1 needs to query Northwind on Server 2. On server 1:
Create a Client Network Alias named NorthwindAlias and point it to Server 2.
Create a Linked Server named NorthwindAlias and map logins.
Write a query referencing NorthwindAlias.dbo.xxxxx, etc.
January 21, 2009 at 9:01 am
Thanks for the illumination. I have run into this problem several times (dev/qa/prod) and now I think I have a glimmer of how to solve this. Thanks!
Arthur
Arthur Fuller
cell: 647-710-1314
Only two businesses refer to their clients as users: drug-dealing and software development.
-- Arthur Fuller
January 21, 2009 at 9:10 am
If my kludge helps, great!
I'd really like to be able to accomplish this trye of thing entirely inside SQL Server (like with a synonyn) instead of relying on having to go to the desktop and run the SQL Server Configuration Manager, etc.
Viewing 9 posts - 1 through 8 (of 8 total)
You must be logged in to reply to this topic. Login to reply