The Bit Bucket

T-SQL 101: 85 Counting rows and column values with COUNT

In previous posts, I looked at how to read data from a table. Now, we need to look at how we do calculations on the data in the table.

The most basic calculation we might do is to count the number of rows in the table. The first example above does that.

What about the asterisk?

But also notice that is has an asterisk in the query. Some people worry about the asterisk being in their queries as usually having an asterisk isn’t a good idea. In fact, some customers have automated systems for checking code, and the automated system might complain about the asterisk.

2021-02-15

SDU Tools: Date of Orthodox Easter in SQL Server T-SQL

Some time back, we added DateOfEasterSunday to our free SDU Tools for developers and DBAs. Given it was the Christian Easter Sunday, almost immediately, I got a request for the Greek Orthodox Easter. That date isn’t of course just the Greek one, so we’ve added a new function DateOfOrthodoxEaster.

It’s based on a concept from Antonios Chatzipavlis. Thanks !

It takes a single parameter:

@Year int - the year to find the date for

2021-02-12

Making a cloud transformation, not just a migration - free course

In the dying days of PASS, one of the attempts at keeping the organization afloat was the introduction of the PASS Pro membership. One benefit of that was access to a series of Learning Experiences. Since the demise of PASS, our friends at Red-Gate have purchased the assets, and that includes those courses.

I was pleased to hear from the Red-Gate team that the courses have now been made available for free, and without any type of paywall/loginwall. That’s just awesome.

2021-02-11

T-SQL 101: 84 Avoiding data type conversion errors with TRY_CAST, TRY_CONVERT and TRY_PARSE

In a previous post, I showed how to use CAST and CONVERT. What I didn’t mention before though, is what happens when the conversion will fail. If I try to convert the string ‘hello’ to an int, that just isn’t going to work. Of course, what does happen, is the statement returns an error.  Same thing happens if I try to convert the 30th February 2016 to a date. There aren’t 30 days in February. Again, an error will be returned.

2021-02-10

Opinion: iPhone12 Pro is an interesting device but a lousy phone

I’d been using an iPhone6+ for quite a while, and it still worked fine. Lately though, I’d been running into things that needed a later version of iOS than what was supported on that phone. So I changed to an iPhone12 Pro.

So far, that’s been a big mistake.

One thing I’ve seen over the years while working with technology, is that development teams often get enamoured with the new features. And they forget to make sure that core functionality works as expected. The core functions seem to get lost in the weeds.

2021-02-09

SDU Podcast 82 with guest Kamil Nowinski now released

I recorded another podcast with an old friend recently. I met Kamil Nowinski in Poland when I was invited to speak at SQL Day. That event is on again this year, but as a virtual event only.

In our consulting work, we use Azure Data Factory frequently. Deploying it, can be a real challenge. Microsoft has a supplied method with ARM templates but that has issues. Kamil produced free tooling that’s in the Azure Marketplace and makes it much easier to work with.

2021-02-08

SDU Tools: Check if Lock Pages in Memory is Enabled on SQL Server

In our free SDU Tools for developers and DBAs, we have a lot of procedures and functions for checking system and database configuration details. One that we were asked for a function for, was the ability to check if the LockPagesInMemory (LPIM) setting was enabled, so we added that.

The function is called IsLockPagesInMemoryEnabled.

It takes no parameters, and returns a bit to indicate if the value is enabled or not.

2021-02-05

SQL: Global temporary tables are almost never the answer in SQL Server

I was doing some consulting recently and reviewing a developer’s code. I was surprised to find extensive use of global temporary tables. Let me start by saying this: global temporary tables are almost never what you should be using.

When I asked why he’d used them, he told me that he wanted the temporary tables that he created in his procedure, to be available to other procedures that were run from within the procedure. So in PROC-A, he was running PROC-B and PROC-C. A temporary table was created in PROC-A and he wanted to be able to use it in PROC-B and PROC-C.

2021-02-04

Book Review: Deep Medicine: How Artificial Intelligence Can Make Healthcare Human Again

I have a deep interest in artificial intelligence and how it will change the world. I regularly present sessions on what I see coming, technology-wise. Many examples in those sessions are based on breakthroughs related to medicine. So I was pleased to get to listen to Eric Topol’s book Deep Medicine: How Artificial Intelligence Can Make Healthcare Human Again.

Eric spends time discussing how much of existing medicine is functional yet quite broken. Very few doctors now really connect with and relate to their patients. Worse, misdiagnoses are becoming far too frequent, arguably because of this disconnection.

2021-02-03

DevOps: Fix: Can't clone an Azure DevOps repository in Visual Studio and SSDT

I’ve been working at a site that uses proxy servers for Internet access. And we were unable to clone a Git repository in Azure DevOps (AzDO) from within Visual Studio (VS). It was quite frustrating.

Visual Studio has got proxy settings and I had configured those:

They live in the system.net node within the settings.

VS was able to get out to the Internet, and I could find and try to connect to projects in AzDO but I couldn’t clone them from within there.

2021-02-02