Press "Enter" to skip to content

Curated SQL Posts

Integer Conversion and Rounding in SQL Server

Steve Jones points out a bit of rounding math:

Imagine that I have someone enter a value for the number of hours to include in a report. I enter 5 and the report divides this in half to go back 2.5 hours and forward 2.5 hours. I run this code at the top of my code block:

Click through for Steve’s example. This ultimately has to do with integer division. If you run the following code, you’ll still get 2 as the result:

SELECT CAST(5.99 / 2) AS INT;

This is because SQL Server discards the decimal during integer casting. DATEADD() simply works with the end result, post-cast.

Comments closed

Essential Settings for SSMS

Rich Benner has some thoughts on configuration:

By default, SSMS does not show row numbers next to your code. That’s not a huge issue when working with smaller blocks of T-SQL. However, when working with larger problems and/or collaborating with colleagues, being able to refer to a row number is invaluable. This is especially important for us here at SQL Solutions Group when we’re in meetings and looking at code. Being able to refer to a line number on somebody else’s screen makes the world so much easier and less confusing.

Line numbers being on should absolutely be a default setting in SSMS. I can’t think of any reason why you wouldn’t want line numbers on. Rich also looks at other ways you can customize the look and feel of SSMS, such as map mode for the vertical scroll bar, organizing pinned tabs, and more.

Comments closed

String Data Types in MySQL and PostgreSQL

Aisha Bukar compares two products:

A very common task in creating a database is to store string data. For example, words, paragraph(s) or even documents. String data types allow you to do just that and store and represent text. They handle everything from simple names and addresses to complex data.

A string is simply a sequence of characters. These characters can be letters, numbers, symbols, or even spaces. For example, “Simple Talk”, “MySQL and PostgreSQL”, “1234” are all strings. Think of each character as a building block. A string is made up of these blocks, arranged in a specific order.

As always, when dealing with different data platform technologies, the small differences are big.

Comments closed

Thoughts on Dark Mode Reports in Power BI

Elena Drakulevska reminds us to think of the user:

Lately, there’s been a lot of hype around dark-mode reports—especially now that dark mode is officially a thing in Power BI. It’s sleek, it’s trendy, and, let’s be honest, it looks pretty cool.

But before we all jump on the dark-mode train, let’s pause for a second. Because, like most things in design, IT DEPENDS.

Click through for a primer on accessibility. Meanwhile, my hottest design take is that dark mode is wildly overrated. Invest in proper task lighting.

Comments closed

Time-Saving Features in Scikit-Learn

Cornelius Yudha Wijaya describes a half-dozen functions:

For many people studying data science, Scikit-Learn is often the first machine learning library they encounter. It’s because Scikit-Learn offers various APIs that are useful for model development while still being easy for beginners to use.

As helpful as they may be, many features from Scikit-Learn are rarely explored and have untapped potential. This article will explore six lesser-known features that will save you time.

The calibration curve function, in particular, drew my attention, especially as I had written that by hand in the past.

Comments closed

Common Power BI Mistakes

Koen Verbeeck lays out some common mistakes people make when developing Power BI reports:

What are some of the most common mistakes when working with Power BI? For example, when a junior colleague starts on a Power BI project for the first time, what are the pitfalls you try to warn them about? What advice would you give them?

The last one hurts me in particular because .pbip and TMDL aren’t compatible with Power BI Report Server.

Comments closed

RegEx Performance in Azure SQL DB

Brent Ozar breaks the bad news:

Regular expressions are a way of doing complex string searches. They can be really useful, but they have a reputation: they’re hard to write, hard to read, and they’re even harder to troubleshoot. Once you master ’em, though, they come in handy for very specific situations.

This post isn’t about their complexity, though. This post is about Azure SQL DB & SQL Server 2025’s regex performance.

Brent’s testing hurts, because I want to use regular expressions, and based on what he’s seen so far, we’re probably still better off using CLR-based regex in SQLSharp.

Comments closed

An Overview of DataDiluvium

Adron Hall has a new tool and a new blog series. The first post is a product overview:

DataDiluvium is a web-based tool available at datadiluvium.com that helps developers, database administrators, and data engineers generate realistic test data from SQL schema definitions. Whether you’re setting up a development environment, creating test scenarios, or preparing data for demonstrations, DataDiluvium streamlines the process of data generation.

The second covers some of the development precepts Adron used:

DataDiluvium is a web-based tool I’ve built designed to help developers, database administrators, and data engineers generate realistic test data based on SQL schema definitions. The tool takes SQL table definitions as input and produces sample data in various formats, making it easier to populate development and testing environments with meaningful data.

The tool is free, so if you’re looking for a sample data generator, check it out.

Comments closed

COPY and \COPY in PostgreSQL

Dave Stokes runs two commands:

PostgreSQL is equivalent to a Swiss Army Knife in the database world. There are things in PostgreSQL that are very simple to use, while in another database, they take many more steps to accomplish. But sometimes, the knife has too many blades, which can cause confusion. This is one of those cases.

Read on to understand what the difference is between these two commands.

Comments closed