Proposed SQL Server defaults: cost threshold for parallelism

A few months ago I suggested that the following settings should be the default for most SQL Server instances: Set cost threshold for parallelism to 50 Disable lightweight pooling if it is enabled Disable priority boost if it is enabled Set optimize for ad hoc workloads to enabled Set max server memory (MB) to a
-> Continue reading Proposed SQL Server defaults: cost threshold for parallelism

Some databases may show a NULL collation in the sys.databases DMV

While working on my Swart’s Ten Percent Rule post last week, I needed to test the Windows version of the script on my SQL Server 2016 instance. Just before removing all the databases, I noticed something interesting when querying the sys.databases Dynamic Management View (DMV). Because the process I had come up with involved setting
-> Continue reading Some databases may show a NULL collation in the sys.databases DMV

Dates and Times in SQL Server: DATEDIFF() and DATEDIFF_BIG()

Last time we looked at adding or subtracting date parts using the DATEADD() T-SQL system function. This week we see how to calculate the difference between two date-time values using DATEDIFF() and DATEDIFF_BIG(). The syntax for both functions is identical:

The only functional difference between them is that the DATEDIFF_BIG() returns values as a
-> Continue reading Dates and Times in SQL Server: DATEDIFF() and DATEDIFF_BIG()

The Golden Gate Bridge partially hidden by clouds

String or binary data would be truncated: get the full picture in SQL Server 2017

SQL Server 2019 Preview (CTP 2.0) introduced a long-awaited improvement to an error message that’s been around in SQL Server for many years, but was unhelpful:

Thanks for nothing, error message. Which table? Which column? What data? This is how the error message looks now:

Notice how the table, column and value are
-> Continue reading String or binary data would be truncated: get the full picture in SQL Server 2017

Create a slipstream installer for SQL Server on Windows

Since the release of SQL Server 2008 Service Pack 1 in April 2009, it has been possible to install SQL Server with media that includes the latest patches, whether they be Service Packs (for SQL Server 2016 and prior), Cumulative Updates, and even hotfixes. There was the hint of a promise with the new servicing
-> Continue reading Create a slipstream installer for SQL Server on Windows

Post image

Dates and Times in SQL Server: AT TIME ZONE

Continuing the series on dates and times in SQL Server and Azure SQL Database, this week we look at the hint AT TIME ZONE. In Azure SQL Database, the regional settings of the database are set to UTC by default. It is also advisable to store dates and times in UTC format on our on-premises
-> Continue reading Dates and Times in SQL Server: AT TIME ZONE

broken glass

Repair SQL Server on Linux after an Ubuntu distribution upgrade

SQL Server 2017 is supported on Ubuntu 16.04 LTS (Long-Term Support), however that version of Ubuntu Linux is now more than two years old, so you may be tempted to update Ubuntu to a more modern release such as Ubuntu 18.04 LTS (Bionic Beaver). Unfortunately (as of this writing), SQL Server 2017 is not supported
-> Continue reading Repair SQL Server on Linux after an Ubuntu distribution upgrade

Dates and Times in SQL Server: DATENAME()

Last time we looked at DATEPART(). This post is all about the DATENAME() function. So many similarities There are many similarities between DATEPART and DATENAME. Where DATEPART returns the date or time part as an integer, DATENAME returns the part as a character string. This DATENAME function also takes two parameters: the date or time
-> Continue reading Dates and Times in SQL Server: DATENAME()

calendar

Dates and Times in SQL Server: DATEPART()

In my previous posts in this series we’ve seen reference to Transact-SQL (T-SQL) functions that are used to get the specific part of a date and/or time (year, month, day, hour, minute, second, etc.). This week we’ll go through one of them and see how it works. Introducing DATEPART, a built-in function that takes two
-> Continue reading Dates and Times in SQL Server: DATEPART()

Dates and Times in SQL Server: the problem with DATETIME

Recently I wrote a post about date and time functions you should never use, which contained an opinion I’ve expressed previously that some people have disagreed with, namely that DATETIME is a terrible data type which you should not be using in new development. The motivation for this position is that a better data type exists. As
-> Continue reading Dates and Times in SQL Server: the problem with DATETIME