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

The Types of Changes

I would guess that most of you reading this piece are database professionals in some sense. Either you work on databases as a developer of some sort (app and/or database) or manage them as a DBA or sysadmin. In working with databases, I'm sure that you need to alter object structures. Maybe you perform a lot of changes, or maybe you just alter the schema occasionally, In either case, you need to make decisions on which changes to make.

I would guess that the most common changes are altering stored procs/views/functions. Often these are to handle new or updated business rules. In those cases, how do you ensure you haven't added regressions? I would hope you had a set of test scripts to verify that your results are correct. If I were very optimistic, I'd hope that you had a set of automated tests, such as those you could write with tsqlt or the Microsoft Unit Test Framework.

I'm sure many of you add new columns to tables. What are these types of changes? Capturing new data? Splitting existing columns or de-normalizing data? In these cases, are you re-examining the data model to ensure the changes make sense?

Maybe even more importantly, if you are capturing new data, do you consider vertical partitions for the table? This can be a good way to separate out data in columns that isn't queried as often. Despite most recommendations, lots of developers will still SELECT * from tables, which can flood the buffer cache with data that isn't often needed by an application. Vertical partitions can reduce the impact of these types of queries.

For those of you that add new data, do you consider using different data types for your new data, or do you have a standard string/numeric/date type that you use? SQL Server (and other platforms) often have a variety of different data types that can save space, while still accommodating the requirements for a change. As an example, many people use datetime as a standard type when they just need a date. In this case, we could save 5 bytes per row by choosing a more appropriate type.

If you add status values or flags, have you considered bit storage for your values? Whether you use the bit datatype or bits in an int, you can dramatically save space in each row. Newer versions of SQL Server include T-SQL functions to help you work with bits, though I would hope most developers can handle simple AND/OR logic against an integer to test if a particular bit is set.

Most software under active development has a need to continually alter and modify the database to meet new requirements. While lots of us have experience in making these changes, and do so often, once we make a change it often becomes enshrined in our production system for years. I would hope that we feel confident in refactoring our code as needed, but the reality of what I often see is that people are loathe to change the database for fear of breaking our software. Even when the refactoring actually improves the performance of the application.

I'm curious what types of changes you often make, and how you go about deciding on the specifics of the change. Let us know about your approach in the discussion. I'm especially interested in how you might handle the various options for changes. Do you assume defaults or are you explicit in how you structure your ALTER code?

You might have a novel way of examining requests and implementing changes that can help others in learning to ensure they make better changes in their own system.

Steve Jones - SSC Editor

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

 
 
  Featured Contents
SQLServerCentral Article

Vector DB implementation using FAISS

utsav from SQLServerCentral

Searching for relevant information in vast repositories of unstructured text can be a challenge. This article explains a Python-based approach to implementing an efficient document search system using FAISS (Facebook AI Similarity Search) for Vector DB and sentence embeddings, which can be useful in applications like chatbots, document retrieval, and natural language understanding. In this […]

External Article

The Ebb and Flow of AI

Additional Articles from Brent Ozar Blog

Everybody’s coasting and looking back. Let’s kick our heels up, get comfortable, and talk big picture industry stuff.

Blog Post

From the SQL Server Central Blogs - Friday Flyway Tips: Chaining Commands for State-based Deployments

Steve Jones - SSC Editor from The Voice of the DBA

One of the cool things I’ve seen with the new Flyway CLI is that I can combine multiple actions together in one call, which can make the process of...

Blog Post

From the SQL Server Central Blogs - Have a Plan for Your Personal Downtime

K. Brian Kelley from Databases – Infrastructure – Security

Most of us know that spending a lot of time on social media and surfing the web isn't good for us, but we still do it. Why? Because it...

T-SQL Fundamentals

T-SQL Fundamentals

Additional Articles from SQLServerCentral

Master Transact-SQL's fundamentals, and write correct, robust code for querying and modifying data with modern Microsoft data technologies, including SQL Server 2022, Azure SQL Database, and Azure SQL Managed Instance.

 

  Question of the Day

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

 

Escaping Like I

I have this data in a SQL Server 2022 table:
PlayerID	PlayerName	PlayerStatus 1	The \%Champ	Active 2	The Champ	Active 3	The_Champion	Active 4	The__Champion	Active 5	The\_Champ	Active
How many rows are returned by this code in SQL Server 2022?
select PlayerName from player where playername like 'The\_C%' escape '\' 
 

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)

Sparse Column Storage

When does a column declared as SPARSE use no storage?

Answer: when it's value is null

Explanation: When the value of a sparse column is null, no space is used. Ref: Sparse Columns - https://learn.microsoft.com/en-us/sql/relational-databases/tables/use-sparse-columns?view=sql-server-ver16

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
Proc cache slowly decreasing in size until restart is required - In SQL 2017 (14.0.3475.1) the size of the proc cache is slowly decreasing. The workload on the instance has the same profile every day and does not change with time. The proc cache size started at a little over 5G and after about 3 weeks is down to below 1G. Just before the previous restart, […]
Proc cache slowly decreasing in size until restart is required - In SQL 2017 (14.0.3475.1) the size of the proc cache is slowly decreasing. The workload on the instance has the same profile every day and does not change with time. The proc cache size started at a little over 5G and after about 3 weeks is down to below 1G. Just before the previous restart, […]
SQL Server 2019 - Administration
EXTENDED EVENTS Track What's Logging In - Simple one looking for a script that can track what's logging in from where for UPGRADE discovery.  
SQL Server 2019 - Development
Using ROW_NUMBER() to increment every time a value occurs - Hello folks, I have some rather unstructured data coming into a staging column from a file. I can guarantee the order of the data on load using a column I am calling RowNumber. I like to group the data using ROW_NUMBER() every time the value 'CreateDate' occurs. Here is current my effort. Thanks if you […]
how to keep report from running automatically when my params all default to null - Hi I'm standing up a report with 9 visible cascading params , none of which needs to be entered.   all will default to null, If i remember correctly , once i set it up, the report will run automatically without the user hitting the run button because all params default that way.  how can i […]
SQL Azure - Administration
Issue with Creating Linked Server from Azure SQL Managed Instance to On-Premises - Hi, Interestingly, I was able to create a linked server in the reverse direction—from the on-premises SQL Server to my Azure SQL MI—using a remote login and password for authentication. However, when I attempt to establish the link from Azure SQL MI to the on-premises SQL Server, it consistently fails. Additional Details: I have an […]
General
When trying to use a LocalDB, I get an error - I tried to find an appropriate forum to post the question. This one seems to be the closest. I'm sorry if I'm wrong. This is a long story, which I haven't time to go into now. I'm starting a new Blazor Web app using .NET 9 and include what's called Individual Accounts (or Individual Users, […]
Powershell
display bytea image - I moved a table from MsSql to Postgresql that had a field defined as Image in Mssql now in Postgres it's a Bytea field. How can I make sure data copied across with success? Is there some code I could run to make sure Image looks correct from PostgreSQL ? Thanks.
Analysis Services
MDX SSAS Calculated measure for last totals + turnovers - I have a measure with totals for specific dates with the LastNonEmpty aggregation, and a measure with turnovers with the Sum aggregation. Help create a measure with totals for each day that would take into account the last known totals + turnovers from the date of the last totals to the current date. I tried […]
Integration Services
PowerQuery.... don't meet SSIS - I have a powerQuery that reads and transforms a table in a PDF.  Works a champ. If I wanted to write the resulting table's data to SQL Server, I can use DAX Studio (kind of) because it creates a newtable and writes the data to it. But I wanted to just map the columns to […]
SSIS package 'Unexpected Termination' status when running from SSISDB catalog - We are trying to run SSIS package to read Access Database (.mdb) files using Native OLE DB\Microsoft Office 12 Access Database Engine OLE DB Provider in the Source Connection Manager. This package ran successfully from Visual Studio 2019 and also from SSISDB catalog in lower end servers. However, executing the package in higher environments resulted in 'Unexpected […]
T-SQL
Count of Total Appointments within 30 days of each Appointment Date - Good Afternoon. I have a Table where each Record: 1) Represents an Appointment. 2) Has a field Appointment Date. What I am trying to achieve is this: For each Appointment date in the dataset I wish to count up all the Appointments which occur within 30 days. For example, for 1st July 2024, I wish […]
SQL Server 2022 - Administration
I need help accessing my local SQLExpress - My PC has been causing me problems for months. I've told my desktop support team. They reimaged my machine, but it hasn't helped. I cannot run SSMS against the LocalDB I get this error: and that's as far as that goes. If I try to connect to LocalDB I get this error: and that ends […]
SQL Monitoring tools - our client wants to implement Third Party SQL Monitoring tool to monitor SQL server Performance. I would like to understand any recommendation that is being implemented to monitor the performance.
Reporting Services in Managed Instance - Hi , one of my on-premises servers one server is having databases and one more server maintain the reporting services . above 2 servers having connectivity between them . we are planning migrate into Azure Managed Instance .do we need 2 managed instance single managed instance . If Single Managed Instance how can we add […]
 

 

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

 

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