Press "Enter" to skip to content

Curated SQL Posts

Adding a UTC Time Zone Indicator to a Date in SQL Server

Bill Fellows fights with the language:

It seems so easy, I was building json in SQL Server and the date format for the API specified it needed to have 3 millsecond digits and the zulu timezone signifier. Easy peasy, lemon squeezey, that is ISO8601 with time zone Z format code 127

SELECT CONVERT(char(24), GETDATE(), 127) AS waitAMinute; Running that query yields something like 2023-05-02T10:47:18.850 Almost there but where’s my Z? Hmmm, maybe it’s because I need to put this into UTC? SELECT CONVERT(char(24), GETUTCDATE(), 127) AS SwingAndAMiss;

Running that query yields something like 2023-05-02T15:47:18.850 It’s in UTC but still no timezone indicator.

Read on for several attempts and what finally did the trick.

Comments closed

CETAS in SQL Server 2022

Eric Rouach shows off a nice extension to T-SQL in SQL Server 2022:

Create External Table As Select or “CETAS” has finally become available on SQL Server with the release of the 2022 version.

After a short setup, we can create various formats files containing any query’s result set. The created file/s must be kept on an Azure storage solution i.e. Azure Blob Storage.

The process also creates an external table reflecting the updated file’s content.

We’ve been able to do this in Azure Synapse Analytics dedicated and serverless SQL pools for a while, so it’s good to be able to create an external table from a SELECT query on-premises, especially considering that it’s the only way we have left to write to external sources using PolyBase.

Comments closed

Charts and Color Over-Use

Rita Fainshtein shows examples of how over-usage of color makes charts harder to read:

Both graphs convey a message of ranking and grouping into categories.

The categories are shown in both cases in a color-coded manner instead of in a hierarchical format. As graph creators, why do we tend to create graphs with color categories?

1. The fear of being boring, one color seems uninteresting, and here we have both colors and icons. This is an “excellent” attribute for a storyteller.

2. Visually representing a group with similar characteristics makes sense.

But can such graphs tell us anything about groups? Are they easy to understand?

Let’s discuss a few aspects of those cases together:

Click through for the full story, including an alternative to using color as a way to categorize data.

Comments closed

Deploying Azure SQL Edge

Kevin Chant takes us to the edge:

Azure SQL Edge is a version of the SQL database engine that is designed to be deployed on IoT (Internet of Things) devices.

It is based on SQL Server 2019. Which means that by default all new databases are created using the SQL Server 2019 compatibility level. You can lower the compatibility level all the way down to SQL Server 2008 if required.

There was some nice functionality in Azure SQL Edge, some of which (like DATE_BUCKET() and DATETRUNC() made it into SQL Server 2022).

Comments closed

Being a Better DBA with the SPIN Model

Eitan Blumin takes us to a seminar:

The SPIN sales strategy is a selling technique that was developed by Neil Rackham in the 1980s. SPIN is an acronym that stands for SituationProblemImplication, and Need-payoff. This strategy is based on the idea that asking the right questions can help you understand your customer’s needs and provide the best solution for them.

When I first heard about the SPIN sales strategy, I was attending a lecture that was delivered to us by a sales and marketing specialist during one of our company meetings several years ago. As a DBA, I initially assumed this strategy wouldn’t be relevant to my job. But as I listened to the presenter explain the SPIN model, I began to see its potential for use in my daily work:

It’s an interesting approach and I like the way Eitan ties it back to database administration. Of course, we could tie it to application development or any of a number of other fields. I, meanwhile, use the Colombo method, in which I ask a series of seemingly-dumb questions, but just before I leave, I say “Oh, just one more question,” and hit the person with the question proving I know that person committed the crime and have enough evidence to make an arrest.

Comments closed

Diffify Updates

Myles Mitchell celebrates a year of diffify:

We’ve just passed an important milestone for diffify: our app for tracking Python and R package releases has just turned 1 year old! To mark this exciting occasion we are delighted to announce an “anniversary update” featuring numerous quality of life improvements. This post will outline the latest changes and tease at some exciting developments in the works…

Check out these recent changes and a little bit of what’s on the horizon.

Comments closed

PayPal’s Data Contract Template Open Sourced

Jean-Georges Perrin makes an announcement:

A data contract is a binding agreement between the consumers and producers of data. You can see it as a data schema on steroids or data schema++. The goal of the contract is to set expectations between the parties. It can be built as fit-for-purpose where the consumers and producer agree on what it should contain or can serve as a brochure for any consumer willing to access the data offered by this (data) product.

Click through to learn more about data contracts and then check out the contract template itself on PayPal’s GitHub repo.

Comments closed

Documenting Group Policy Objects with Powershell

Patrick Gruenauer builds a report:

Active Directory Group Policies (GPO) enables you to control user and computer settings. It is important to document them. In this blog post I am going to show you two PowerShell commands which create a GPO HTML Report. Let’s dive in.

To store all GPO Settings from all GPOs in one file run this command. Don’t forget to provide your domain name and the path of the report file.

Click through for that code snippet, as well as another one which builds an HTML report for each GPO.

Comments closed

Adding Help to Your Powershell Code

Robert Cain helps those who help themselves:

Having good help is vital to the construction of a module. It explains not only how to use a function, but the purpose of the module and even more.

Naturally I’ve included good help text in the ArcaneBooks module, but as I was going over the construction of the ArcaneBooks module I realized I’d not written about how to write help in PowerShell. So in this post and the next I’ll address this very topic.

Read on for Robert’s thoughts on the topic, including standard ways to add content comments so Powershell’s built-in Get-Help cmdlet works for you.

Comments closed