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

Where to Test Your Code

The last 10-15 years in software development have seen a widespread embracing of unit testing. Before the popularity of mobile phones and their apps, most of the organizations I'd worked in gave lip service to automated unit testing, and often even more complex integration/system tests.

These days, it seems more and more people embrace unit testing, and I hear about that often from customers and attendees at events. I don't often hear about more comprehensive integration and system testing, I found an interesting article from the Pragmatic Engineer that looked at how the Bluesky social network was built. The article is partially paywalled, but I  have subscribed because of the interesting thoughts they publish. In this article, there was a really interesting part of the article on testing. This is a section titled "Integration tests over unit tests".

This isn't described in any detail, but there is a note that the priority is for integration tests. There are unit tests, but I'm guessing this means that they write mostly integration tests first and then perhaps fill in with unit tests. The article does note that the backend is heavy on integration tests, looking to test the flow of data through the network. I assume network means their application here.

I think a lot of companies think about skipping unit testing in the database and instead might run some sort of integration tests from the application that hit the database. At least, I hope they do this. If they use unit tests that mock the database, that's not necessarily a great way to ensure that the things in the database work as expected. Data types, defaults, rules/constraints, etc. All of these things might be different in a database over time, which is why devs need a database that is regularly updated from production (though is likely smaller in dataset size).

I can see some value in looking at integration tests more than unit tests. If we can only test so much because of time pressures, ensuring that the flow of read/write to and from the database makes sense. Queries as well, since potentially there are writes that store data and queries that read or aggregate data that might be transformed somehow in the database. Imagine writing a field, but having queries that read from a computed column that has normalized the data somehow. Or even triggers that have changed the data.

I am a bit fan of testing, and I think there is value in database unit testing, but I also understand that many people struggled to get started there. If you aren't going to do database unit testing, then ensure that you are running integration tests that call through to a database. I realize this can be a hassle to set up in a pipeline but building better quality software means some investment in automated testing. That requires a way to build and update dev/test databases over time. A crucial part of embracing DevOps in the database.

Steve Jones - SSC Editor

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

 
  Featured Contents
SQLServerCentral Article

Control OneLake with Storage Explorer – Data Engineering with Fabric

John Miner from SQLServerCentral

In this new article, we examine how to work with OneLake storage.

External Article

Two Tweaks for Faster Backups with Ola Hallengren’s Scripts

Additional Articles from Brent Ozar Blog

Ola Hallengren’s free maintenance solution is widely used as a replacement for SQL Server maintenance plans. It’s a more powerful, flexible tool for backups, corruption checking, and index & statistics updates. If you’re using it for backups, there are two quick, easy changes that can dramatically reduce your nightly job runtimes.

Blog Post

From the SQL Server Central Blogs - Talkie - a simple, private, responsive interface for LLMs

Bert Wagner from Bert Wagner

Watch this video on YouTube
I like using ChatGPT. But I don't like the $20/month price tag for using OpenAI's app, especially given the API costs fractions of a cent.
So...

Blog Post

From the SQL Server Central Blogs - How I Effortlessly Dockerize Python-Based AWS Lambda Functions

Adetokunbo Ige from Adetokunbo Ige

As a Software Engineer, i would like to learn how to dockerize my Python Fast API Framework and use this dockerize application in my lambda function. This will allow...

Learn T-SQL Querying

Learn T-SQL Querying

Additional Articles from SQLServerCentral

Troubleshoot query performance issues, identify anti-patterns in your code, and write efficient T-SQL queries with this guide for T-SQL developers

 

  Question of the Day

Today's question (by Steve Jones - SSC Editor):

 

The Same Operator Precedence

Which groups of logical operators have the same precedence?

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

 

 

  Yesterday's Question of the Day (by Steve Jones - SSC Editor)

Disable Memory Grant Feedback Persistence

In SQL Server 2022, how can I disable memory grant feedback persistence?

Answer: ALTER DATABASE SCOPED CONFIGURATION SET MEMORY_GRANT_FEEDBACK_PERSISTENCE = OFF;

Explanation: You use the ALTER DATABASE SCOPED CONFIGURATION command. Ref: Memory Grant Feedback Persistence - https://learn.microsoft.com/en-us/sql/relational-databases/performance/intelligent-query-processing-memory-grant-feedback?view=sql-server-ver16#percentile-and-persistence-mode-memory-grant-feedback

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
Script - We have about 30 databases in server A.  All of them need to migrate to server B. Decided to use the backup & restore method. The dat file & log file paths are will be different on source server & destination server. I am looking for the script to backup all the databases on the […]
SQL Server 2016 - Administration
SHOWPLAN documentation - The most recent documentation I can find is this https://learn.microsoft.com/en-us/previous-versions/sql/sql-server-2008-r2/ms189602(v=sql.105) which is showing as retired. Does anyone know if there is a newer version which applies to 2016? Apologies for asking for assistance with searching. I have searched extensively and not been able to find it. I'm guessing the content is still accurate for 2016 […]
SQL Server 2019 - Administration
Using TDE Best Practice - I am trying to understand when best to enable TDE. Our Asst. Director has been pushing to encrypt everything when we can due to more and more cyber crime. We have implemented all SQL instances are backing up using encryption as well as all our SQL connections are encrypted. As far as TDE, Should we […]
Program Code giving duplicate errors where no duplicates exist - On our Java Hibernate program it is giving a duplicate value on an insert on a table where there are no values remotely close to the vales being inserted. The developers have stepped through their code, connecting  from other source code, though the program has not changed in 2 years. Running the insert directly in […]
Add alarms to database when a query, stored procedure, SSIS package hangs - Hello SSC, I am a SQL Server developer that has some DBA skills. I need to add alarms to an instance or database when a query, stored procedure, or SSIS package hangs for longer than a few hours. I did not see anything in the security or maintenance drop down in SSMS. Any assistance would […]
MSOLEDBSQL/MSOLEDBSQL19 - Linked Servers and encryption - Yes I know Linked Servers can be evil... but they can be fine and fair enough for small data sets. If trying to setup a linked server and using either the MSOLEDBSQL that ships with SQL2019 or the newer one MSOLEDBSQL19 (that by default wants to be encrypted and trust a valid certificate)... Given using […]
SQL Server 2019 - Development
Looking for recommendations for reporting technologies replacements - Here at work I've been maintaining an old ASP.NET WebForms app. I was assigned it when I came to this job. I never met the original developers, as they'd all left before I was hired. Anyway, this old app has several problems, include multiple .NET Frameworks have been used for the 9 projects that comprise […]
How to get calculated values from a derived(?) table? - Here is my filtered dataset: I would like to calculate the time difference between each 0 and 1 that occur sequentially.  In this case, the time difference between each time stamp, since the 0's and 1's alternate.  So, from item 10 to 11 - that's just over 25 minutes, from 11 to 12 - almost […]
Anything that is NOT about SQL!
I got tired of always having my feet to the fire, so after 42 years I fixed it! -
SQL Server 2022 - Administration
sp_server_diagnostics in ErrorLog - I have the following in the SQL Errorlog, that was never there before: sp_server_diagnostics encountered a long delay that was 2.5 times more than the repeat interval between two consecutive diagnostics result generations. The repeat interval: 300000000, the elapsed time of this diagnostics result generation: *****, the elapsed time between the latest two diagnostics result […]
should i make as many datafiles for temdb as many cpus i have - hi, q1 As people said if u ghave GAM conention then u can go for adding as many datafiles of equal size in temdb as many cpus u have is it correct in sqlserver 2019 vesion also. q2) right click on sqlserver instance then select reprots->perfomance dashboard report then click io statistics . i have […]
dbcc clonedatabase issue - I have used the 'dbcc clonedatabase'   schema-only backup procedure many times in the past to have control over what I want to backup . Now I have a freshly installed  SQL2022 Standard Edition  instance that throws the duplicate record error message , like: Cannot insert duplicate key row in object 'sys.syssingleobjrefs' with unique index 'clst'. […]
Cannot Force Encryption - SQL Will Not Take Cert - Hi there, I have a sql server on government AWS and we're trying to satisfy a requirement to force encryption on the server.  I have tried creating self signed certs and we have obtained official certs from DoD, but the SQL configuration manager will not accept the certificates.  I have been able to get it […]
SQL Server 2022 - Development
Login failed for user sa sql server 2022 - windows server 2022 - i got the login failed error for user sa, but not always so I went to server properties - security - server authentication change to windows authentication mode and change again to sql server and windows authentication mode, and restart sql server. this happened when i upgraded to sql 2022, I have Service Pack 13 […]
Login failed for user sa sql server 2022 - windows server 2022 - i got the login failed error for user sa, but not always so I went to server properties - security - server authentication change to windows authentication mode and change again to sql server and windows authentication mode, and restart sql server. this happened when i upgraded to sql 2022, I have Service Pack 13 installed, […]
 

 

RSS FeedTwitter

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

 

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