|
|
|
SSCommitted
      
Group: Moderators
Last Login: Monday, August 13, 2012 1:06 PM
Points: 1,928,
Visits: 224
|
|
|
|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Friday, March 08, 2013 10:18 AM
Points: 47,
Visits: 165
|
|
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
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Friday, May 17, 2013 10:10 AM
Points: 164,
Visits: 256
|
|
| 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. :)
|
|
|
|
|
SSC Eights!
      
Group: General Forum Members
Last Login: Wednesday, April 03, 2013 8:23 AM
Points: 966,
Visits: 927
|
|
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.
|
|
|
|
|
SSCarpal Tunnel
       
Group: General Forum Members
Last Login: Friday, May 17, 2013 11:21 AM
Points: 4,317,
Visits: 9,216
|
|
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 Problems are opportunites brilliantly disguised as insurmountable obstacles.
How to post questions to get better answers faster Managing Transaction Logs
|
|
|
|
|
SSCarpal Tunnel
       
Group: General Forum Members
Last Login: Yesterday @ 6:03 AM
Points: 4,787,
Visits: 1,335
|
|
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: http://www.mssqltips.com/tip.asp?tip=1076
|
|
|
|
|
SSC Eights!
      
Group: General Forum Members
Last Login: Wednesday, April 03, 2013 8:23 AM
Points: 966,
Visits: 927
|
|
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.
|
|
|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Friday, March 08, 2013 10:18 AM
Points: 47,
Visits: 165
|
|
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
|
|
|
|
|
SSC Eights!
      
Group: General Forum Members
Last Login: Wednesday, April 03, 2013 8:23 AM
Points: 966,
Visits: 927
|
|
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.
|
|
|
|