Problems displaying this newsletter? View online.
SQL Server Central
Featured Contents
Question of the Day
Redgate SQL Change Automation
The Voice of the DBA
 

The Importance of Testing

Today we have a guest editorial from Grant Fritchey as Steve is away on his sabbatical.

It’s almost impossible to overstate just how important testing is to those of us in IT. Yet, it’s so frequently overlooked, ignored, played down, and just flat out dismissed, that I have a hard time understanding it. Very recently, NASA (you know, rocket scientists) reported that if they had not caught a bug in the software of the new manned vehicle, Starliner, it could have cost the lives of the crew (or at least the loss of the capsule in a test).

I’m a huge advocate for adopting DevOps practices. Getting teams to communicate and tear down unnecessary barriers that are slowing down development and deployment are so important for modern systems in order to move at the speed of business. Oh, yeah, and building in automated testing at multiple stages in the process in order to ensure that you’re not just introducing bad code to production faster. I advocate for a thorough DevOps process because, in my experience, and supported by our recent 2020 State of DevOps Survey, DevOps adds protection to your production environments. It doesn’t speed things up by taking away protection. It speeds things up by ensuring that your code is good before you get to production. DevOps and testing are joined at the hip.

But hey, let’s not talk DevOps. Let’s just talk technology. How do you know if the new index you’re proposing will speed up your queries? Don’t tell me execution plan, because that is not a measure of performance. Are you, maybe, going to do a little testing? See how many reads you had before and after the addition of the index? How fast the query was before and after? Yes.

What about introducing a new technology? We’re moving to SQL Server 2016 (I’d advocate for at least 2017, but that’s another discussion), but we must keep our databases in 2012 compatibility mode because of reasons. Just go with me on this. Can we still use clustered columnstore indexes and update the data in them? I honestly don’t know the answer, but you know what’s going to tell me? Testing.

Most of us are not going to kill people because we introduced a bug into production. However, we could cost the company millions. How are we going to move ahead as technologists in an ever changing, fast moving infrastructure that consists of change? Testing.

 

Grant Fritchey

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

Redgate SQL Change Automation
 
 Featured Contents

Handling Aggregations on a Poorly Designed Database

aveek22 from SQLServerCentral

When the database design is not great, you may have to write some creative queries to get what you need.

Using SQL Server RAND Function Deep Dive

Additional Articles from MSSQLTips.com

Dr. Dallas Snider, a MSSQLTips author, mentioned that SQL Server RAND() function could generate random values uniformly distributed from 0 through 1, exclusive. He generated random numbers from the normal distribution with a specific mean and standard deviation.

The Dangers of using Float or Real Datatypes

Additional Articles from Redgate

Floating point datatypes accommodate very big numbers but sacrifice precision. They are handy for some types of scientific calculations, but are dangerous when used more widely, because they can introduce big rounding errors.

From the SQL Server Central Blogs - T-SQL Tuesday 123: Life Hacks to make your day easier

Diligentdba 46159 from Mala's Data Blog

This month’s T-SQL Tuesday is hosted by Jess Pomfret. Jess’s theme is ‘Life Hacks to make your day easier’. She talks of some things we do to make life...

From the SQL Server Central Blogs - Starting and Stopping SQL Server with PowerShell

Steve Hughes from DataOnWheels

Have you ever had this issue? You are trying to explore new features of SQL Server or you want to install the latest version for some testing, but SQL...

 

 Question of the Day

Today's question (by Kendra Little):

 

DBCC Meaning

What does "DBCC", as in (DBCC SHOW_STATISTICS) stand for? (Pick the answer defined in the current Microsoft documentation on DBCC) 

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

 

 

 Yesterday's Question of the Day (by Kathi Kellenberger)

The "Median" Function

There are many aggregate functions available in SQL Server. Which function can be used to calculate a median?

Answer: PERCENTILE_CONT

Explanation: According to Microsoft, the PERCENTILE_CONT function "Calculates a percentile based on a continuous distribution of the column value in SQL Server. The result is interpolated and might not be equal to any of the specific values in the column." This function can be used to calculate a median when the numeric literal parameter is 0.5. Here's an example from AdventureWorks which returns a list of years and the median TotalDue:

SELECT DISTINCT YEAR(OrderDate) AS OrderYear, 
    PERCENTILE_CONT(0.5) WITHIN GROUP(ORDER BY TotalDue) 
    OVER(PARTITION BY YEAR(OrderDate)) AS MedianOrder
FROM Sales.SalesOrderHeader;

(Note: DISTINCT is used because this function will return the answer for every row in the results.) List of years and median order PERCENTILE_DISC is similar, but it will return an actual value from the data and not interpolate the result. It does return the median when applied to an odd number of rows. There is no MEDIAN function in T-SQL, but it is possible to create a custom CLR function. The AVG function returns the average, which is not the median.

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 - Administration
Procedure master..xp_cmdshell - Msg 15121, Level 16, State 10, Procedure master..xp_cmdshell, Line 1 [Batch Start Line 2] An error occurred the execution of xp_cmdshell. A call to 'CreateProcessAsUser' failed with error code: '1314'.   working on migrating from SQL Server 2008R2 to 2017 when creating proxy account and running xp_cmdshell using sqlserver login I am getting the error […]
SQL Server 2017 - Development
Table locks while inserting into the table - Hi , I am facing a deadlock while i am trying to insert data into a table. At the same time we have app users working on the application , which inserts data in our table. SO, in order to avoid deadlock , can i use table lock? if so , which table lock to […]
Data Extraction Tools - Currently using SQL Stored Procedure to write a script joining multiple to form a data and insert into another table.   Is there any other data extraction tools can replace above?
SQL Server 2016 - Development and T-SQL
How to add unique row numbers if there is a duplicate records in sql server - Hi All, I am looking for a way to add unique sequence number to my result set in sql server  even though there is duplicates or not. For Example, If first 3 rows are duplicate rows then the sequence should be 1 instead of 1,2,3. Then if the 4th,5th row is duplicate then sequence should […]
Development - SQL Server 2014
bcp hold the csv files and doesnot write to the csv file - Hi, The following is sql statement set @sql = 'bcp xxxxx.dbo.CsvTemp out D:/EDI/INCOMING/test1.csv  -c -t, -T -SDBNAME' DBNAME - server name.. which is part of a stored procedure SP1. When i call this SP1 from .net website... BCP utility just creates the file at the location , doesnot write anything to it and holds the […]
SQL 2012 - General
How to write loop below with best practice performance ? - I work on SQL server 2012 I have temp table get data from excel and based on data exist on excel i insert on table inside loop temp table always have big amount of data may be at least 5000 or 10000 or 15000 or more I need every iteration increased by 5000 rows insert […]
SQL Server 2012 - T-SQL
Date Range Dynamic Column count in sqlserver - dear All   Above format, I need sql server Query  
SQL Server 2019 - Development
Country Shape Files and STIntersect - A friend of mine asked me a really interesting question... Imagine a flight path (I guess a linestring of (Longitude, Latitude) points)… I'm trying to figure out all the countries a flight would overfly. I could do it with STIntersect and STBuffer (to give myself some margin for error). But where do I get the […]
Inline and Multi-statement table-valued functions - When you run an inline or a multi-statement table-valued function, either type of function will return a table. Is that table a temporary table? Does that table have local scope or global scope? If #2 is yes, how can you control if the table returned will have local scope or global scope?
Reporting Services
How to export a report to Word from Visual Studio 2019? - I installed Visual Studio Enterprise 2019, Version 16.44 in my PC (Windows 10). I also downloaded and installed SQL Server Reporting Services Projects separately and successfully. I made a SSRS report in my Visual Studio successfully. However, I don't know how to export my SSRS report to Excel and Word. I can't find any web […]
SSRS Parameters OLEDB - Hi I am using OLEDB to connect to an Oracle. I have two parameter which I want to use in my dataset query. What should I put for the parameter. Dataset Query: Parameter positions are indicated as YearParameter and MonthParameter SELECT        DATA_FACT2.HMO_ID, DATA_FACT2.HRS_AUTH, DATA_FACT2.HRS_PAID, DATA_FACT2.Year, DATA_FACT2.Month, DATA_FACT2.RPT_TYPE FROM            DATA_FACT2 WHERE        (DATA_FACT2.Year = YearParameter) AND (DATA_FACT2.Month […]
Powershell
Get Secondary replica name in a variable - I need to pass secondary replica name in a variable to a command for example I get the primary replica name using Get-DbaAvailabilityGroup -SqlInstance ListenerName| Select-Object * -ExpandProperty PrimaryReplicaServerName How do I get the secondary replica name?   Thanks
Strategies and Ideas
Adding a column to a Type 2 SCD - Hello, I have a standard type 2 SCD that is performing well however the business have asked for additional info that needs to be added to the DIM. My issue is that if I add a column, it will set all existing rows to not current and insert a new row for all thus doubling […]
Integration Services
Conditional split variable - All, I'm trying to use a variable in a conditional split condition. I tried a few combinations similar to the following: CreationDate >= (DT_DBDATE)"01/01" + [@$Package::Year] && CreationDate < (DT_DBDATE)"01/02/2019" The year parameter contains a four digit year. Would someone mind advising the correct syntax? I did some searching but with no success. Thanks
Microsoft Access
Find and Copy Data from Another Table - Hi: I want to update DOB in Customers table from Info Table Two tables Customers ID, Name, DOB, Blood Type Info ID, DOB Scenario ======== Find where ID of “Customers” = ID of “Info” then copy “DOB” from Info to “DOB” Customers Note: there is data already in DOB of Customers, i want to update […]
 

 

RSS FeedTwitter

This email has been sent to {email}. 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.
©2019 Redgate Software Ltd, Newnham House, Cambridge Business Park, Cambridge, CB4 0WZ, United Kingdom. All rights reserved.
webmaster@sqlservercentral.com

 

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -