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

Changing Data Types

Recently I was working with a customer that is trying to smooth out their database development process. They noted that a lot of changes tend to take a significant amount of time and impact their availability. They came to Redgate to see if Flyway might be a way to improve the effectiveness of their internal groups that build, deploy, and manage their database software.

We can help, but often when I get called to help architect things, we are trying to decide if the customer is a good fit for our solutions. Since we work on a subscription model, we want to be sure customers are happy and get value from their decision. Otherwise they have a poor experience and don't renew. This might be because they aren't ready, or it might be that the question wasn't considered of whether our solution fits their environment well. In any case, I usually dig into the goals and challenges they've faced with their current process.

In this case, they found that developers often changed data types of columns to better match the data being stored. That can be a disruptive change, and while Flyway does some amazing things, the software is still bound by the rules of making changes by the platform. In this case, SQL Server changes can sometimes be metadata-only changes, which are fast. Sometimes this isn't the case.

After the call, I started to wonder how often people change data types? I've rarely done this, and honestly, I've used a zero-downtime pattern a few times to add a new column, move data, use triggers, and then when I'm sure all data is moved, drop the old column. Changing types in place seems like a bad idea some of the time.

Sometimes it's not a big deal, but I prefer to avoid any potential problems if I can.

That got me wondering. How often do you change data types in existing tables/columns? Is this because of poor data modeling? Changing requirements? Or are you lucky enough to avoid this?

Or maybe you're unlucky in that you can't change those poorly chosen types.

Steve Jones - SSC Editor

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

 
 Featured Contents
SQLServerCentral Article

Answering Questions On Dropped Columns

Cláudio Silva from SQLServerCentral

Answering a couple of questions from the previous posts about dropping columns.

External Article

Query Hint Recommendation Tool in SSMS 22

Additional Articles from MSSQLTips.com

SQL Server Management Studio keeps adding features, but unless you look you probably don’t notice. In this article, we look at the new Query Hint Recommendation Tool in SSMS 2022 and how this can be used.

Technical Article

Webinar: Compliance Without Compromise: Test Data Management That Finally Fits

Steve Jones - SSC Editor from SQLServerCentral

You know you shouldn't have production data in test environments. But every time you look at fixing it, the options feel impossible: enterprise tools that cost six figures and take months to implement, or DIY scripts that sort of work until they don't. Join this webinar on Mar 18 to learn more.

Blog Post

From the SQL Server Central Blogs - Why I stopped using MCP for AI coding stuff

HamishWatson from The Hybrid DBA's Blog

Something has shifted quietly in 2026. The developers I know/respect—the ones actually shipping, not just posting about shipping—stopped talking about MCP. No dramatic announcement. No hot take thread. They...

Blog Post

From the SQL Server Central Blogs - AI: Blog a Day – Day 4: Transformers – Encoder, Decoder, and Attention

Vinay Thankur from Vinay Thakur

Continuing from Day 3 where we covered LLM models open/closed and their parameters, Today on Day 4 I would like to write about the Transformer architecture — the foundation...

SQL Server 2025 Query Performance Tuning: Troubleshoot and Optimize Query Performance

Site Owners from SQLServerCentral

A new era of SQL Server is here, and this latest edition of Grant Fritchey’s best-selling dive into SQL Server query performance can ensure your queries keep up.

 

 Question of the Day

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

 

Fun with JSON II

I have some data in a table:
CREATE TABLE #test_data
(
    id INT PRIMARY KEY,
    name VARCHAR(100),
    birth_date DATE
);

-- Step 2: Insert rows  
INSERT INTO #test_data
VALUES
(1, 'Olivia', '2025-01-05'),
(2, 'Emma', '2025-03-02'),
(3, 'Liam', '2025-11-15'),
(4, 'Noah', '2025-12-22');
If I run this query, how many rows are returned?
SELECT t1. AS row,
       t2.*
FROM OPENJSON(
     (
         SELECT t.* FROM #test_data AS t FOR JSON PATH
     )
             ) t1
    CROSS APPLY OPENJSON(t1.value) t2;

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)

Restoring On Top II

I have a database, DNRTest, that has a number of tables and other objects in it. The other day, I was trying to mock up a test and ran this code on the same server:

-- run yesterday
CREATE DATABASE DNRTest2
GO
USE DNRTest2
GO
CREATE TABLE NewTable (id INT)
GO

Today, I realize that I need a copy of DNRTest for another mockup, and I run this:

-- run today
USE Master
BACKUP DATABASE DNRTest TO DISK = 'dnrtest.bak'
GO
RESTORE DATABASE DNRTest2 FROM DISK = 'dnrtest.bak' WITH REPLACE

What happens?

Answer: This fails as there aren't enough options specified.

Explanation: This fails. While the REPLACE would overwrite the DNRTest2 database, the physical names of the files need to be addressed. We cannot overwrite the mdf/ldf files from DNRTest, which are stored in the backup file. We would need a WITH MOVE statement to adjust the files needed for DNRTest2. Ref: RESTORE - https://learn.microsoft.com/en-us/sql/t-sql/statements/restore-statements-transact-sql?view=sql-server-ver17

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 2019 - Administration
Can an Azure App Service Managed Identity be used for SQL Login? - I'm fairly certain I know the answer to this from digging into it yesterday, but would like a second opinion. We're (finally) moving some applications to cloud-native, using Azure App Services and the developer would like to, if possible, use a Managed Identity and Key Vault for the application to connect to the SQL Server […]
SQL Server 2019 - Development
how to write this query? - hi everyone I am not sure how to write the query that will produce the expected results.  Basically, I need to convert data found in columns and put them into rows.  I have provided sample data and screenshot of expected result.  Can someone please help me with this? Thank you Sample Data drop table if […]
SQL Azure - Administration
Azure Synapse database refresh - Hi Team, I am trying to refresh the Azure Synapse Dedicated pool from production to lower environment. Is there a standard documented process which we can follow similar to Azure SQL database. I have searched in various forums but none of them were worked in our environment due to policy restrictions. Please do the needful. […]
Editorials
I'm thinking about submitting some articles - I've written some documentation on using different Markdown types of files on GitHub. It's a series of documents. Some of them are long, but others are short. Anyway, what I don't know is if I should just submit them as separate articles or if they would qualify as a Stairway. Would someone with SQL Server […]
Not Just an Upgrade - Comments posted to this topic are about the item Not Just an Upgrade
Why End-User Testing Is Even More Important with AI - Comments posted to this topic are about the item Why End-User Testing Is Even More Important with AI
Writing as an Art and a Job - Comments posted to this topic are about the item Writing as an Art and a Job
Rollback vs. Roll Forward - Comments posted to this topic are about the item Rollback vs. Roll Forward
Article Discussions by Author
Restoring On Top I - Comments posted to this topic are about the item Restoring On Top I
Designing Delta Tables with Liquid Clustering: Real-World Patterns for Data Engineers - Comments posted to this topic are about the item Designing Delta Tables with Liquid Clustering: Real-World Patterns for Data Engineers
String Similarity II - Comments posted to this topic are about the item String Similarity II
Supervised versus Unsupervised Training of an Artificial Neural Network - Comments posted to this topic are about the item Supervised versus Unsupervised Training of an Artificial Neural Network
Foreign Keys - Foes or Friend? - Comments posted to this topic are about the item Foreign Keys - Foes or Friend?
Fun with JSON I - Comments posted to this topic are about the item Fun with JSON I
SQL Server 2022 - Development
Dynamic Unpivot - I have a table I didn't design that has tons of repeating groups in it... here's an abbreviated version: USE tempdb; go CREATE TABLE [dbo].[Toxicity2]( [RecordID] [int] IDENTITY(1,1) NOT NULL, [PatientID] [int] NOT NULL, [Cycle] [tinyint] NOT NULL, [ANEMIA] [tinyint] NULL, [Causality1] [tinyint] NULL, [Relatedness1] [tinyint] NULL, [ALOPECIA] [tinyint] NULL, [Causality2] [tinyint] NULL, [Relatedness2] [tinyint] […]
 

 

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

 

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