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

Daily Coping Tip

Let go of other people’s expectations of you

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.

Choosing State Over Migrations

I ran across an article about state v migration based development for Snowflake. While I think that this article is a bit slanted because the author is building a tool, it does present some good reasons why people worry about migration-based approaches. This article also references a work from Alex Yates on the two approaches.

Everything we do in relational databases, and in some other platforms like Snowflake, is a migration script. If you run SQL Compare and get the differences, you are generating a migration script. It might contain lots of changes, but it's still a migration script. I wish I could write CREATE OR ALTER TABLE scripts, but that's not a part of the SQL specification (yet).

The concerns in the article are valid, though some are a bit outdated. I know that I am biased a bit as my employer, Redgate Software, sells tools in this area. However, over the years, we've supported and worked on both approaches. We do a lot of research, and I get to provide feedback on the good and bad of how we approach the problem. Ultimately, I think the world is very chaotic and we should be as flexible as possible with developers.

I find that most developers like the state approach. Even if they want to write code themselves, having an easy way to capture the state of objects and keep track of them is useful. When we see a table difference, we want to see a view of the old table and new table in a CREATE TABLE statement: the state approach.

For deployments, we always need migration scripts, but we want to build them as appropriate for the situation. Cherry-picking out specific changes is often what we need when urgent hot fixes need to be deployed, or a piece of work isn't tested. In those cases, we might need to deploy some changes and not others, which often require us to put a subset of changes into a migration script(s). That's a hassle, and these situations are often where we find humans making mistakes.

Ultimately I prefer state sometimes and migrations others. If I had to pick only one, it would be migrations, but I'd ensure I had a state view of the schema using a tool like SQL Compare. I want to be able to see history and capture changes. in a human-readable format.

One isn't better, and both have advantages and disadvantages. We are often under pressure to be more like DevOps software developers, adaptive and agile. We can use either state or migrations to do this. The important thing is that your whole team understands those and works together to smooth out your database deployments.

Steve Jones - SSC Editor

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

 
 Featured Contents
Stairway to SSAS Tabular

Stairway to SSAS Tabular Level 1: Why use Analysis Services

Thomas LeBlanc from SQLServerCentral.com

In this first level of the SSAS Tabular stairway, learn the benefits of implementing an SSAS solution.

Tower Loan: Monitoring our estate and insights for your success

Additional Articles from Redgate

Join Kevin Davis, DBA Manager at Tower Loan to hear their playbook for successful distributed estate monitoring, and the role of SQL Monitor.

Learning the SQL GROUP BY Clause

Additional Articles from MSSQLTips.com

Learn about the various ways to use the GROUP BY command to summarize and rollup query results. We look at the basics with examples as well as using group by rollup, cube and grouping sets.

From the SQL Server Central Blogs - Login Timeouts

Grant Fritchey from The Scary DBA

I was recently approached at work about a company that was seeing tons of timeouts in SQL Server. I was asked how to troubleshoot this. There are lots of...

From the SQL Server Central Blogs - How to Design Backups in SQL Server?

nelsonaloor from PracticalSQLDba

The Recovery Point Objective (RPO) and Recovery Time Objective (RTO) are basic concepts related to the information to be recovered and the time that it will take to recover....

 

 Question of the Day

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

 

Changing a Container Collation

I am starting up SQL Server 2019 in a Linux container. I want to change the collation from the default case insensitive to case sensitive. What parameter do I use to do this from the Docker command line?

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 Backup Operator in MSDB

I have a default US English installation of SQL Server 2019 and connect as a sysadmin. I create a new user with this script:

USE [master]
GO
CREATE LOGIN [JoeBackup] WITH PASSWORD=N'XXXxxx', DEFAULT_DATABASE=[sandbox], CHECK_EXPIRATION=OFF, CHECK_POLICY=OFF
GO
USE [sandbox]
GO
CREATE USER [JoeBackup] FOR LOGIN [JoeBackup]
GO
USE [sandbox]
GO
ALTER ROLE [db_backupoperator] ADD MEMBER [JoeBackup]
GO

This user logs in and is placed in the sandbox database. The user, JoeBackup, then executes this script:

USE msdb
GO
SELECT * FROM dbo.backupmediaset AS b
GO

What happens?

Answer: The query executes successfully

Explanation: By default, each database includes a guest user. The guest user is a member of the public role. This is the case in the msdb database. The default permissions for msdb include SELECT permission to dbo.backupmediaset. Ref:

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 2016 - Development and T-SQL
Surprising results when analyzing Bltzcache results.... - Blitz Cache reveals that the 50 most expensive queries run against the production servers are raw statements, not wrapped in stored procedures, and earlier, Blitz revealed plan cache instability, with most plans being compiled in the last 24 hours despite the server having last been restarted a fortnight back.  We have memory pressure which we […]
Result set different after breaking up case expression in where - I'm back again with more dumb questions. This time I am dealing with refactoring a single select with nested case expressions in the where clause. I'm trying to optimize this, and in attempting to do so, I broke up the query into multiple selects w/ union alls. This does run quite a bit faster, but […]
Sending Locking Alert - I have 2 tables the first one holds the dbwait information(locks), and the second table holds the db sessions related to the locks. I'm in build block stage where I have the files loading to SQL, and will make updates to the Table Defs(PK,Index) after some testing.  Just trying to work thru the logic of […]
Export empty JSON with headers & footers - Hello, I have inherited a process that utilises an SSIS package and related stored procs that creates a JSON file. The file we create looks like - A number of objects in an array in a nested hierarchy. If we have no data from our process at present we create an empty file. What I […]
Administration - SQL Server 2014
SQL server becomes slow after running dbcc checkdb - We are having an issue of SQL server slowness and I’m unable to find out why. After the dbcc checkdb job completes the other processes like the ETL jobs, other maintenance jobs just run for a longer time. we are having performance issues that we are forced to restart the server whenever this happens. This […]
how much memory that we need for SQL - Hi All, Our server has a Datawarehouse database is like 600 GB ( 500 GB for data file only ) and memory is ONLY 8 GB ( 5 GB for SQL ) . There are only 2 Databases and the other database is very small (58 MB) SQL edition is SQL 2014 I feel The […]
SQL 2012 - General
Adding a PRIMARY KEY CLUSTERED - Is there a T-SQL way to add the following to an existing table that already has data in it?: PRIMARY KEY CLUSTERED ( [CALL_ID] ASC, [DATE] ASC, [TIME] ASC, [CALL_TYPE] ASC, [DOMAIN] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] TEXTIMAGE_ON […]
SQL Server 2019 - Administration
How migrate on SQL database to AWS - Can any one tell step by step procedure to How migrate on-premises SQL  server  database to AWS.
Back up and restore Synchronized database - Hello I have 2 database servers one as a primary and another as a secondary. I have synchronized them through availabity group settings. The vendor of the database wants to do some updates on the database locally which means i have to take a back up of the database and send them the back up. […]
SQL Server 2019 - Development
Index design on large and "wide" tables - We have a database of some statistical measures for some entities per day. I can't share the full schema, but trying to simplify so one still can follow the generic idea. The basic design is following: CREATE TABLE dbo.StatisticsTable ( statisticsType INT, timePeriod INT, entityID INT , statisticalMeasure1 NUMERIC(19,12) ... , statisticalMeasureN NUMERIC(19,12) primary key […]
Issue with the change of the column precision to be 2 decimal places - Hello, I need to  change the % sales vs forecast column precision to be 2 decimal places instead of whole numbers. The confusing part is that I already have a format function and 'Po' as a '%" at the end, so I am trying to understand how I can make a % with two decimal […]
Results-To-Text , Programatically - I sometimes run queries against an IBM DB2 database, using an  old Navigator tool that has limited functions. In some cases I want the results in 1 pane, so I can do various string searches with CTL-F. Typical # of result rows is less than 1000. It's probably equivalent to SQL 7 as far and […]
How to return a range value based on the first day of year and the value of row - Hello, i have a table called Events, the value of that table like as bellow : create table Events ( id int, code_events varchar(10), Events varchar(10), Events_start datetime, Events_end datetime ) insert into Events values(1,'AC_83','Event 1','2020-07-15','2020-07-30') insert into Events values(2,'AC_84','Event 2','2019-06-01','2030-07-30') insert into Events values(3,'AC_86','Event 3','2020-07-15','2022-12-15') insert into Events values(4,'AC_83','Event 1','2020-09-15','2025-04-30') insert into Events values(5,'AC_87','Event […]
Reporting Services
Data Driven Subscription by Email? - Hi, Try to find an example of a data driven subscription Via Email. What I would like to do is run a report with each row has an employee associated with a client. I would like to send via email only the clients associated with the client .   Thanks
Analysis Services
MDX Filter() for a calculated measure - Hi folks, I am still quite new to MDX and have severe problems with the following task (beg your pardon for German language): The measure [Leistung] is aggregated on the database as max(). Another, calculated measure [Leistung Zeitpunkt] is needed , wich delivers the date belonging to the maximum-value. I have tried to achive this […]
 

 

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

 

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