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

Daily Coping Tip

Recognize that you have a choice in what to prioritize

I also have a thread at SQLServerCentral dealing with coping mechanisms and resources. Feel free to participate.

For many of you out there working in a new way, I'm including a thought of the day on how to cope in this challenging time from The Action for Happiness Coping Calendar. My items will be on my blog, feel free to share yours.

Cone of Uncertainty

When we make decisions for how to build some feature in software or design an entity in a database, we are usually working with very incomplete information. We are more likely to be wrong than right in some way. It might not matter, but often we do end up adjusting our code in response to feedback from someone.  This could be in response to other developers, QA, or maybe customers.

For database design, this can be problematic. I believe that any database code that gets to production is likely to live there for 10 years. Maybe longer. Maybe shorted if we find a way to change it, but that can be tough, especially for tables. Since other software (apps, reports, etc.) get built on top of database structures, it becomes challenging to change these across time.

We need to use solid design and modeling principles we can rely on. That's good, in that it helps us produce reliable, understandable designs that our developers can count on. However, are we good at learning, growing, and changing to adapt to new requirements? Do we experiment at all?  How much can we try things without deploying something we have to live with for ten years? I don't know, but I find that too many people implement structures without thinking about the future.

DevOps tries to lead us to make small changes, adjusting as needed. That is tough with database structures, but not impossible. There are patterns for evolving out databases without breaking applications, but this does require some good application practices. No SELECT *, no insert statements without column lists, and a few other things. These aren't hard, but they do require some adherence to good data layer practices from other software.

We also need to balance the need to follow efficient modeling practices, with the understanding that clients rarely think about all the possibilities when they describe their needs and data relationships. Often they consider the happy path and describe that well, but forget the edge cases, the exceptions, the places where strict normalization can cause problems.

I treat all requests as though they are in the cone of uncertainty. This is an art, but I approach most data specifications from a client with a large grain of salt. I assume they are only thinking about 70-80% of the cases and I should think about where I can leave flexibility in my design.

We call ourselves software engineers and data engineers, and there is a case to be made for us following good design principles across projects. However, I view that most of our projects are often groundbreaking in some way, tackling problems in new ways and the "engineering" is balanced by a bit of art.

Approaching work with some respect for the uncertainty works well. Using database refactoring processes and being willing to adjust designs over time is a way that DevOps has worked well for me, allowing me to slowly tailor the database to meet the demands of an application. By assuming I will need to change my data model over time, I'm more willing to do so as the need arises.

Steve Jones - SSC Editor

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

 
 Featured Contents
SQLServerCentral Article

10 Considerations for a Database Migration to AWS RDS

Br. Kenneth Igiri from SQLServerCentral

This article includes 10 things that you should consider when migrating to the cloud, with an example using RDS that explains how these are applied to an actual database being created.

External Article

5 Database DevOps Trends Landing on your Shoulders

Additional Articles from Redgate

Are these challenges heading your way?

Join us on Nov 15th at PASS Data Summit to discuss key trends that impact Database DevOps, such as Containerization, and Cloud Build/CI systems. Reserve your place now.

External Article

Bringing SQL Server Data Quality Tools to Your Company

Additional Articles from MSSQLTips.com

Learn how and why you should be using Melissa's data quality components that fully integrate into SSIS packages to fix data problems and save your company money.

Blog Post

From the SQL Server Central Blogs - Monitor Cardinality Feedback in SQL Server 2022

Grant Fritchey from The Scary DBA

It’s possible for you to see new technology at work if you use Extended Events to monitor cardinality feedback. To put it simply, cardinality, the number of rows being...

Blog Post

From the SQL Server Central Blogs - My experience working with notebooks in Azure Data Studio

DataOnWheels from DataOnWheels

I’ve seen notebooks used in Azure Data Studio on multiple occasions. I really like the concept of notebooks, having done some work within Azure Databricks notebooks, but not extensively....

 

 Question of the Day

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

 

Robust Plans

What does the ROBUST PLAN query hint do?

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)

The Delete Order

I create a table, dbo.car, with an identity column in it. I add 7 rows to this table with various inserts. I then want to execute this statement:

DELETE TOP(1) FROM dbo.car

Which row is deleted?

Answer: Any single row could be deleted.

Explanation: As with a SELECT, if there is no ordering or filtering, any row could be deleted by a TOP 1 statement. In this case, the first row is often deleted as this is the first one encountered in a table scan, but that is not guaranteed. Ref: DELETE - https://learn.microsoft.com/en-us/sql/t-sql/statements/delete-transact-sql?view=sql-server-ver16

Discuss this question and answer on the forums

 

Featured Script

Convert Lat/Lon Decimal Degrees to Trigesimal Codes

Todd M. Owens from SQLServerCentral

Simplified latitude / longitude in 10 fixed bytes.

WITH
coordinate_pair (id, lat_deg, lon_deg) AS ( -- Replace with your source table
/**/SELECT 109876, 32.747338, -97.083928 UNION ALL
SELECT 115432, 30, -90
),
trigesimal_glyph_set (txt) AS ( -- Any trigesimal set of 30 characters
/**/SELECT '0123456789BCDFGHJKLMNPQRSTVWXY' -- not the same set as "Natural Area Code"
),
trigesimal_pair_place /*RECURSIVE*/ (id, lon_pct, lon_glyph
, lat_pct, lat_glyph, row_nbr ) AS (
/**/SELECT id
, CAST( ( lon_deg + 180) / 360 AS decimal(9,9))
, CAST( NULL AS char(1))
, CAST( ( lat_deg + 090) / 180 AS decimal(9,9))
, CAST( NULL AS char(1))
, 0
FROM coordinate_pair
UNION ALL
/**/SELECT id
, CAST( lon_pct * 30 - FLOOR( lon_pct * 30) AS decimal(9,9))
, CAST( SUBSTRING(txt, FLOOR( lon_pct * 30) + 1, 1) AS char(1))
, CAST( lat_pct * 30 - FLOOR( lat_pct * 30) AS decimal(9,9))
, CAST( SUBSTRING(txt, FLOOR( lat_pct * 30) + 1, 1) AS char(1))
, row_nbr + 1
FROM trigesimal_pair_place
CROSS JOIN trigesimal_glyph_set
WHERE row_nbr < 5 ) /**/SELECT id , STRING_AGG ( lon_glyph,'') WITHIN GROUP (ORDER BY row_nbr ) AS x_cd , STRING_AGG ( lat_glyph,'') WITHIN GROUP (ORDER BY row_nbr ) AS y_cd FROM trigesimal_pair_place GROUP BY id

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 - Administration
How to remove unallocated space after partitioning - Hello, I've recently done partitioning on a table (postcode column) and created new filegroups for each postcode. Now that it is no longer using the PRIMARY filegroup, the file size is still as it is. How do I reduce it or shrink it as it appears that there is a huge unallocated space? I attached […]
SQL Server 2016 - Development and T-SQL
Project for DTSx can't be opened in Visual Studio 2017 - Hello, I copied entire folder of the project/soultion for DSTx (SSIS) on another Windows 2019 server/SQL 2016. But the project is not working there. Unsupported This version of Visual Studio is unable to open the following projects. The project types may not be installed or this version of Visual Studio may not support them. For […]
combine values as pivot - I have the following results after running a SQL. The first 2 columns are the result of the SQL.   The 3rd column is what I try to achieve. So combining all values where name is the same in a new column. Is this possible using a pivot? or any other suggestion? Thanks  
Administration - SQL Server 2014
Mirroring transport endpoint error:8474 - I see several posts regarding this error. I feel I don’t need to stop and start the endpoint. We are using SQL 2014. I am seeing in the error log. An error occurred in a service broker/database mirroring transport connection endpoint,Error:8474, state:11. (Near endpoint role: Target, far endpoint address). The database mirroring is in healthy […]
Development - SQL Server 2014
How Can I let Insert, update and delete sql statement work in a user-defined fun - I encode Insert and update statements in a user-defined funtion on some tables(not temp table and not table variable) in SQL Server, but when I use Execute command to create this function in SQL Server management studio, it shows Invalid use of a side-effecting operator 'UPDATE' within a function. Invalid use of a side-effecting operator […]
SQL 2012 - General
I need some urgent help! - I am working with SQL Server and needed some help with a query   When you run this "SELECT 'YES' it would print Yes in column 1 Row 1, I want to print a dynamic list, so it doesn't look at a existing table. So if criteria 1 is met it would print YES/NO/Maybe and […]
SQL Server 2019 - Administration
SQL 2019 SQLBrower.exe - Hi, Has anyone encountered an issue like this before - I have a 3 node active, active passive cluster running a variety of SQL Editions, 2014 up to 2016. Recently I installed SQL 2019 (CU17) and the SQLBrowser service although running was not working. No firewall, no blocked port, no missing SQLBrowser.exe file, Service running […]
Pitfalls of setting up MySQL as a linked server in SQLEXPRESS - I have a database in MySQL 5.7 that I need to link to a DB in SQLEXPRESS so that I can selectively migrate data. The MySQL server is 64-bit. Whenever I try to install 32-bit MySQL Connector/ODBC 8.0, and set the MYSQL up as a 32-bit System DSN on the machine with SQLExpress and SSMS […]
SP_whoisactive duration vs Profiler Duration for SP_prepexec statements - Hi I have an application that executes statements using sp_prepexec and an sp_unprepare after each statement. In profiler a common statement will take 5 reads, no CPU and sub millisecond. When I capture the same statement in Sp_whoIsActive, it gives a duration of 4 seconds, and sometimes hundreds of thousand of reads. Does anyone know […]
SQL Server 2019 - Development
STAT command conindex equivalent - Hi, does any one whether there is an equivalent function on SQL to the STATA command conindex. We have a user processing 194 million rows of data via STATA using this command and it would be a whole lot easier if it was at he SQL level. Any help very welcome.. Thanks, Eamon    
SQL bug - Hello, I am trying to run a query but it does not like the date format in two of the strings. This query works on other colleagues laptops so I am wondering if it is a bug with the laptop. the problematic string is copied just below: [DatesInYear].date_1 >= '2021-11-01 00:00:00.000' AND [DatesInYear].date_1 <= '2021-11-30 […]
Fact Table Agreggate with Sum - I need help populate de Fact Table in my DW. i need to sum the quantity and other columns (this is just a small part of the data source) which has to be grouped by Family,SubFamily and SubSubFamily. I generate a surragate key for the sales dimension but when i populate the fact table  i […]
Inserting Recurring Notes on Scheduled Dates - I am having a problem with a T-SQL stored procedure whose purpose is to insert recurring notes into the tblNotes table from the tblRecur table where the schedule specified in a record in tblRecur applies to a given date. Here’s my code: ALTER procedure [dbo].[uspAddRecurringNotesOnDate]( @OwnerID int, @Dt datetime ) AS -- Get table of […]
how to get 3 days moving average in my sql - I have 2 tables: users, traffic. The first table consists of the users information (id, name, user_type) . The second table consists of the time of each visit to the website:(user_id, visited_on, time_spent). Trying to write a query to show the 3 day moving average of time spent on the website for users.user_type='user'. Also, avg_time_spent […]
Integration Services
Oracle Connector missing in VS 2019 - I need to convert our existing 2017 SSIS packages to 2019. Many of these connect to Oracle 19c dbs. In VS2017 we used the Attunity connector successfully. I currently have VS2017 and VS2019 installed on my development machine to allow me to work through the conversion. I have installed VS2019 with the required extensions and […]
 

 

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

 

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