August 14, 2014 at 2:01 pm
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
September 5, 2014 at 7:42 am
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.
Viewing 2 posts - 31 through 31 (of 31 total)
You must be logged in to reply to this topic. Login to reply