Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Using Views


Using Views

Author
Message
Steve Jones
Steve Jones
SSC-Dedicated
SSC-Dedicated (36K reputation)SSC-Dedicated (36K reputation)SSC-Dedicated (36K reputation)SSC-Dedicated (36K reputation)SSC-Dedicated (36K reputation)SSC-Dedicated (36K reputation)SSC-Dedicated (36K reputation)SSC-Dedicated (36K reputation)

Group: Administrators
Points: 36282 Visits: 18752
Jason Shadonix (8/3/2014)


We use synonyms here and there, and have never had any issues with them "not working".

We use SPs over SQL code in our application whenever possible. In some organizations it might shift a lot of load to the DBAs or make the developers have to wait on DBAs to get them changed if needed, but it also allows changes to be made "on the fly" a lot easier in many cases without the need to do a code release. It just depends on the organization/environment you're working in.


Want to write about how you use synonyms? Always looking for descriptions of real world implementations.

Follow me on Twitter: @way0utwest
Forum Etiquette: How to post data/code on a forum to get the best help
My Blog: www.voiceofthedba.com
TheRedneckDBA
TheRedneckDBA
SSCommitted
SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)

Group: General Forum Members
Points: 1876 Visits: 2592
Steve Jones - SSC Editor (8/13/2014)
Jason Shadonix (8/3/2014)


We use synonyms here and there, and have never had any issues with them "not working".

We use SPs over SQL code in our application whenever possible. In some organizations it might shift a lot of load to the DBAs or make the developers have to wait on DBAs to get them changed if needed, but it also allows changes to be made "on the fly" a lot easier in many cases without the need to do a code release. It just depends on the organization/environment you're working in.


Want to write about how you use synonyms? Always looking for descriptions of real world implementations.


Hmm...I could probably come up with something in the next week or two.

The Redneck DBA
phickey
phickey
Grasshopper
Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)

Group: General Forum Members
Points: 12 Visits: 122
Synonyms can be used to simplify code when doing cross-database work. They are especially helpful for standardizing code when the external database name varies from environment to environment. Consider these databases:
* MyDB_dev
* MyDB_prod
* YourDB_dev
* YourDB_prod

Besides the environment-specific databases, this would work where there is a set of databases (MyDB and YourDB) for each project or client.

MyApplication connects to either MyDB_dev or MyDB_prod. Code in MyDB (or MyApplication) needs to use YourObject in YourDB. Rather than using messy/repetitive/dynamic code to access either YourDB_dev.YourObject or YourDB_dev.YourObject , we encapsulate the database name differences in synonyms.

On MyDB_dev: CREATE SYNONYM dbo.YourObject FOR YourDB_dev.dbo.YourObject;
On MyDB_prod: CREATE SYNONYM dbo.YourObject FOR YourDB_prod.dbo.YourObject;

Once the synonyms are set up (correctly), all code is instance-agnostic, and there is no risk of getting dev data in prod.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search