SQLServerCentral - www.sqlservercentral.com

A community of more than 1,600,000 database professionals and growing

Featured Contents

The Voice of the DBA

Synonyms

I am not talking about words that have the same meaning. I am talking about the SQL Server object that allows you to create an alternate name for a database object. The subject came up on a discussion forum that was connected to an article about using custom schemas. I thought it would be a good topic to bring into the light today.

First, if you are not familiar with synonyms in SQL Server, you can get a good overview and a general understanding from an article that Jason Shadonix wrote a while back. I don’t want to rehash Jason’s article, but synonyms can be very helpful in certain situations. I wrote an article recently about the importance of a consistent server setup.

In that article I advocate for database names to be named the same across prod, test, and dev. Still, some shops have a need or choose to use a _test or _dev appended to their production database name in their test or dev environments. In those cases, synonyms can really help. When you need to access data tables, views, stored procs, functions, on different databases or linked servers, you can create a synonym. This ensures that your queries and stored proc calls don’t have to change when you promote your code between dev, test and production.

Of course, you should be careful in how you use them. In some cases, it might be appropriate to name the synonym in such a way for it to be obvious to others that it is not the actual SQL object. Perhaps adding "S" to the front of the original object name when you create the synonym, for example. In other cases, you might want to obfuscate the actual underlying object with a synonym. In any case, synonyms are a useful tool for the SQL professional to be aware of.

If you haven’t used or heard of synonyms before, click a few links. Do a few Google searches and learn about them. They have the potential to help you save some time and they might make your life easier when it comes to promoting code to different environments.

Do you use synonyms in your work place? If you do, share how you use them and any issues you have run across with them in your systems?

Ben Kubicek from SQLServerCentral.com

Join the debate, and respond to today's editorial on the forums

ADVERTISEMENT
Database DevOps

Database DevOps Demo Webinar

Learn how to automate your database deployments alongside your app code in this free demo webinar. Register now

SQL Compare

The industry standard for comparing and deploying SQL Server database schemas

Trusted by 71% of Fortune 100 companies, SQL Compare is the fastest way to compare changes, and create and deploy error-free scripts in minutes. Plus you can easily find and fix errors caused by database differences. Download your free trial

Featured Contents

 

Keep Column Headers Visible in SSRS

Ginger Keys Daniel from SQLServerCentral.com

Keep column headers visible while scrolling down the page of SSRS reports. More »


 

Bootstrap 4 and Self-validating Forms

Additional Articles from SimpleTalk

Validating the user input of a web form is important for security and data quality. In this article, Dino Esposito explains how to validate a form and add undo capability with Bootstrap 4. More »


 

From the SQLServerCentral Blogs - Quick and Easy XE for Azure DB

Jason Brimhall from SQLServerCentral Blogs

The Cloud It has been a minute since I gave much love or attention to Extended Events in Azure SQL DB.... More »


 

From the SQLServerCentral Blogs - What is the Max Degree of Parallelism setting for SQL Server?

Justin Figg from SQLServerCentral Blogs

Max Degree of Parallelism is a setting that is often changed to improve performance in SQL Server.  What exactly does... More »

Question of the Day

Today's Question (by Steve Jones):

What versions of SQL Server are provided by Microsoft as container images?

Think you know the answer? Click here, and find out if you are right.


We keep track of your score to give you bragging rights against your peers.
This question is worth 1 point in this category: containers.

We'd love to give you credit for your own question and answer.
To submit a QOTD, simply log in to the Contribution Center.

ADVERTISEMENT

Exam Ref 70-774 Perform Cloud Data Science with Azure Machine Learning

Prepare for Microsoft Exam 70-774 and help demonstrate your real-world mastery of performing key data science activities with Azure Machine Learning services. Designed for experienced IT professionals ready to advance their status, Exam Ref focuses on the critical thinking and decision-making acumen needed for success at the MCSA level.  Get your copy today from Amazon.

Yesterday's Question of the Day

Yesterday's Question (by Thomas Franz):

What will the following statement return:

 SELECT REPLACE('abc', NULL, 'd') AS first, REPLACE('abc', 'a', NULL) AS second

Answer: NULL / NULL

Explanation:

The REPLACE() function will return always NULL, if one of its three parameters is NULL.

So answer 2 (NULL / NULL) is correct.

This can become tricky, if the function parameters are variables (or "worser" parameters given to the procedure, where you use REPLACE())

Ref: REPLACE() - click here


» Discuss this question and answer on the forums

Database Pros Who Need Your Help

Here's a few of the new posts today on the forums. To see more, visit the forums.

SQL Server 2017 : SQL Server 2017 - Administration

Build a db server just for reporting purpose - We are using 2017 Enterprise version of SQL server.  Database is dataware house db. Reports are built upon these database...


SQL Server 2017 : SQL Server 2017 - Development

Query - --My Query to get Space left in a data file. CREATE TABLE ##ALL_DB_Files ( dbname SYSNAME, fileid smallint, groupid smallint, INT NOT NULL, INT...


SQL Server 2016 : SQL Server 2016 - Administration

configure listener AG in named instance - Hello everyone i have two instance sql server with instance named serveA \ instance1 && serverB \ instance2 each instance listens on a dynamqiue...

SQL Memory & Tempdb usage - Hi Can someone confirm this please - my thoughts are that SQL has 3 main components in RAM - Proc cache ( about 2...


SQL Server 2016 : SQL Server 2016 - Development and T-SQL

Storing a hash of a row - Hi Folks, First of all, happy new year to you all! TL;DR - I need to store a calculated hash value from a...


SQL Server 2014 : Administration - SQL Server 2014

Update stats - Question: in my production server I had noticed the update stats job was failing for few days due to deadloock.....


SQL Server 2012 : SQL 2012 - General

Does Stored Proc Complete if Machine Rebooted? - I am running SSMS on my machine in the US and connecting to a server located elsewhere in the world.  I...


SQL Server 2008 : SQL Server 2008 - General

How Check string of Boolean expression is return true or false - Hi Guys, I have a requirement in my project is how to check string of boolean expression is true or...

SQL connection error 53 ? - Hi, windows 2008 R2 64 bit SQL 2008 R2 64 bit I had checked as below, everythings working fine but not able to...


SQL Server 2008 : T-SQL (SS2K8)

Trigger not working properly - Hi. I have a table A in which datq gets inserred through stored procedure. I also have insert trigger on that...

how to do this join? - Say I have 2 tables like this. CREATE TABLE #TableA (Period CHAR(7), SomeValue INT)


Data Warehousing : Integration Services

SSIDB catalog error - Hi,  I am unable to create SSISDB catalog and get the .bak missing error. Now, I do see the Intergration services...


SQL Server 2005 : CLR Integration and Programming.

Translate Sql Query to Clr - Hello, How can I write the following query in c# clr ? CREATE FUNCTION SQL_HT (  @param1 INT,  @param2 INT)RETURNS@tablo TABLE(   colon1...

This email has been sent to newsletter@newslettercollector.com. To be removed from this list, please click here.
If you have any problems leaving the list, please contact the webmaster@sqlservercentral.com.
This newsletter was sent to you because you signed up at SQLServerCentral.com.
Feel free to forward this to any colleagues that you think might be interested.
If you have received this email from a colleague, you can register to receive it here.
This transmission is ©2018 Redgate Software Ltd, Newnham House, Cambridge Business Park, Cambridge, CB4 0WZ, United Kingdom. All rights reserved.
Contact: webmaster@sqlservercentral.com