SQLServerCentral - www.sqlservercentral.com

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

Featured Contents

Featured Script

The Voice of the DBA

The Right Connection

Travis-CI had some staffers connect to the wrong database and truncate production tables. Needless to say this caused an outage and disrupted their business. Hopefully they didn't lose too many customers, but they certainly did not help their reputation. I'm sure there are more than a few customers trying to decide if they continue to trust the company or move their Continuous Integration (CI) processes to another platform.

I've done this before. Not shut down a company, but I have actually truncated a production table by mistake. Well, not TRUNCATE, I mean, who runs that. But I have run a DELETE without a WHERE clause and killed a lookup table in a production database. Fortunately I had a copy of the table elsewhere and could rebuild it in minutes. Only a few customers had their work interrupted and only for a portion of our system. The point is that I've been a very good DBA, with a lot of success and experience, and I still make mistakes.

Often this type of mistakes comes about because we get busy, and we keep connections open to different systems. When we might be developing code against a schema that is close to production, it's easy to forget which database we're working on. Someone calls with a problem or we fight a fire, and we run some code. We fix the issue, stress bleeds away and we go back to work, but forget to switch connections or tabs. Then we run some code that would be fine in development, but causes issues in production.

SSMS has colors for a connectionSQL Prompt has tab coloring by system and database, as do some other products., which can help, but it isn't perfect. One thing I've found with colors is that if I use them constantly, my mind starts to filter out the color. I don't always realize the outline of the tab is a different color. This is especially true if I have the need to switch back and forth between both production and non-production systems. I've tried running two instances of SSMS, which helps, but at times I'll forget which one I'm working with and make a connection to a production server from a non-production instance of SSMS.

Ultimately, we need to be careful. I know one friend that has no access to production and must hop through an RDP session and connect to a production database. However, if you run your RDP session in full screen, how often would you forget that you're in the SSMS on the hop system and not in SSMS on your local machine.

I don't know if there's a good solution. Many of the convenience features that make life easier, like reconnecting tabs when I restart SSMS are great, however, they can compromise security and safety. I don't know if there is a good solution, but I'd certainly like more checks against ad hoc issues occurring in production systems. Maybe some sort of lock against certain instances that prevents destructive execution on certain instances or databases without some confirmation. I love SQL Prompt preventing me from running code without WHERE clauses, but that isn't always enough. At least not for me.

Steve Jones from SQLServerCentral.com

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


The Voice of the DBA Podcast

Listen to the MP3 Audio ( 4.4MB) podcast or subscribe to the feed at iTunes and Libsyn. feed

The Voice of the DBA podcast features music by Everyday Jones. No relation, but I stumbled on to them and really like the music.

ADVERTISEMENT
SQL Monitor

Don’t just fix SQL Server problems, prevent them from happening

SQL Monitor helps teams looking after SQL Server be more proactive. Not only does SQL Monitor alert you to current issues, it gives you the information you need to stop them happening in the future. Download SQL Monitor now and get a 14 day free trial

SQL Prompt

Become a more efficient SQL developer with SQL Prompt

Learn how to write SQL faster and more efficiently with these exclusive short videos from Data Platform MVPs and SQL Server experts. With SQL Prompt you can strip out the repetition of coding and write SQL 50% faster. Check out the tips

Featured Contents

 

Do you check your backups?

Michael Higgins from SQLServerCentral.com

Backups. Are you confident you can restore? Do you have a process that ensures you can recover your systems? Learn how one system works in the cloud. More »


 

SQL Server Graph Databases – Part 2: Querying Data in a Graph Database

Additional Articles from SimpleTalk

Along with Graph Databases, Microsoft has introduced the new MATCH function for querying them. Robert Sheldon explains how to use the new function. More »


 

5 challenges to scaling DevOps at enterprise level

Many large enterprises launch small DevOps initiatives within certain departments, but subsequently find that scaling DevOps across the organization faces a number of challenges that must be overcome. More »


 

From the SQLServerCentral Blogs - Azure SQL Database and Columnstore Indexes

Arun Sirpal from SQLServerCentral Blogs

I have come to understand the importance of using columnstore indexes when my queries are aggregating and scanning across many... More »


 

From the SQLServerCentral Blogs - Change SQL Server Collation – Back to Basics

Jason Brimhall from SQLServerCentral Blogs

One of my most favorite things in the world is the opportunity to deal with extremely varying database and environment... More »

Question of the Day

Today's Question (by Evgeny Garaev):

Let's suppose you have two instances of SQL Server 2017, one on Linux and another one on Windows. Is it possible to set up log shipping between these two instances?

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: SQL Server 2017 on Linux.

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

Expert T-SQL Window Functions in SQL Server

Expert T-SQL Window Functions in SQL Server takes you from any level of knowledge of windowing functions and turns you into an expert who can use these powerful functions to solve many T-SQL queries. Replace slow cursors and self-joins with queries that are easy to write and fantastically better performing, all through the magic of window functions. Get your copy from Amazon today.

Yesterday's Question of the Day

Yesterday's Question (by Steve Jones):

I've loaded a flat file into an R dataframe. The source data looks like this:

 GameDate Visitor Home VisitorScore HomeScore 20180315 Oklahoma URI 78 53 20180315 WrightState Tennessee 47 73

Once loaded, I find that I get this result:

 > class(ncaa.2018$GameDate) [1] "integer" 

How can I change the GameDate column to a date in a new dataframe?

Answer: ncaa.firstweekend = transform(ncaa.2018, GameDate=as.Date(as.character(GameDate), "%Y%m%d"))

Explanation:

I can use the as.Date function to change a value to a date. In this case, the data was loaded as an integer, so I need to make it a character first. Otherwise, the as.Date will use the integer value and add that number of days to an origin date.

Ref: Date and Times in R - click here


» Discuss this question and answer on the forums

Featured Script

Flexible Statistics Update

Ugur Yorulmaz from SQLServerCentral.com

  1. Please create the stored procedure
  2. Execute the procedure in debug mode first: EXEC sp_FlexibleUpdateStatistics @Debug=1  this will not do anything except listing the statistics to update.
  3. Please execute the procedure with the parameters that satisfy your needs

More »

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

Migration of DB from server to server - Hi All, I have recently come across a new error with little info about why this is happening.  I am currently...

Backing up multiple SQL instance and databases using 3rd party software - Any recommendations - Hello, We are looking to have a centralized software management tool for backing up SQL Server databases that can also provide...


SQL Server 2017 : SQL Server 2017 - Development

Error Processing Cube from SSIS package run as a SQL Job - Hi, I am trying to upgrade a SQL server with Analysis Services to SQL 2017 cu5, 14.0.3023.8, (I tried CU4 before...

Removing stored procedures to move to cloud - I got an interesting email today about cutting back on the reliance of the applications on databases and plans to...


SQL Server 2016 : SQL Server 2016 - Administration

PUBLIC server role vs PUBLIC database role - Dear Everyone I am conducting a database cleanup exercise to remove all unnecessary privileges from the PUBLIC role per the...

SQL Server services and domain accounts / permissions - Dear Everyone i hope you are doing great I am going to ask a topic which has probably been asked...

Shrinking Transnational Log File - Hi All, I have posted similar question here 7 or 8 years ago. Now I am unable to find that post....


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

Create /replace the sensitive data ( first Name , last Name ) with some random values generated - Hello ,  I have a situation where the company does not want to show actual values to the user ( loan information)...

Get all index definitions from all databases and all tables - Hi all I need to get all the indexes from all tables in all databases including:- Database name Table name Index name Index Columns Included columns I've...


SQL Server 2014 : Administration - SQL Server 2014

Learning about clustered index - So let's say I have a table called student (ID int, FirstName varchar(20), LastName varchar(20)) which is 100 GB in...


SQL Server 2014 : Development - SQL Server 2014

Join on field of varying length - Hi Folks, Looking for advice on the following query I'm trying to alter: SELECT

Use uniqueidentifier field in place of int - Hi All, I'm trying to populate a temp table. Here is the temp table: CREATE TABLE #SESDMVESEnrollData (   ContractNumber nvarchar(50) not null,  ...


SQL Server 2012 : SQL 2012 - General

Log Backup question - Hi Currently we did a full back up of a database every night. The recovery model was set to full. However,...


SQL Server 2012 : SQL Server 2012 - T-SQL

Search within a string and return value(s) - Hello, I have this test table: CREATE TABLE #T2 ( VARCHAR(100)) INSERT INTO #T2 () VALUES ('https://www.abc123.com/search?breadcrumbs%5B0%5D=red-big-widget&breadcrumbs%5B1%5D=red-long-big-widgets&cc=LUNERATOOBS&facet.multiselect=true&page=1&q=*&rows=15&son=0&sort=price+asc&start=0&filter=(category:"1289

What permissions do you need to run jobs via SQL Agent? - I've googled my issue all weekend, but can't seem to solve the problem So basically, I have a query, when I...

last entry, first entry - Hello I want to prepare a stock list of last entry , first entry DECLARE @IN TABLE (STOCK INT,ID INT, DATE_ DATETIME,AMOUNT...


SQL Server 2008 : SQL Server 2008 - General

Activity monitor > %processor time - Hi Team, In my sql server 2008R2, Activity monitor > Overview. %Processor time is not showing. do we need to do any configuration...

Msg 2715, Level 16, State 7, Line 2 Column, parameter, or variable #4: Cannot find data type varchar(50) - I have a table that I wanted to drop and recreate by changing some of the data type from INT...


SQL Server 2008 : T-SQL (SS2K8)

I need to "group" two rows of data, but cannot seem to figure it out - my table is simple it has 1,000's of rows.  one row is the account balance in USD, and the other row (and they are...


SQL Server 2005 : SQL Server 2005 Integration Services

Error when attempting to Dynamic set the Connection String to an Excel OLE DB DEstination Connection - I get an error when attempting to Dynamic set the Connection String to an Excel OLE DB DEstination Connection. I can...

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