The Bit Bucket

T-SQL 101: 89 Logical order of T-SQL SELECT queries

It’s unfortunate that the SELECT query in SQL isn’t written in the order that operations logically occur (if not physically). I suspect that’s one of the things that makes learning SQL a bit harder than it needs to be.

Without getting into really complex queries, you need to understand the logical order of the operations.

FROM

The starting point is to determine where the data is coming from. This is normally a table but it could be other sets of rows like views or table expressions.

2020-09-28

Fix: Power BI - Couldn't publish to Power BI

I saw the above message when working with one of my clients today. The error says Only users with Power BI Pro licenses can publish to this workspace. And that would make sense if they hadn’t already purchases Power BI Pro licenses for the user.

I checked online, and there were a number of comments about people seeing this error. There were the usual suggestions of logging out and back into Power BI. There was even one who’d quoted a Microsoft support person who said that Pro licenses don’t work for up to 24 hours after you purchase them. (That sounds dubious to me).

2020-09-07

Congratulations to Dr Georg Thomas !

Many years ago, I spent a lot of time in universities. I ended up finishing my studies at QUT in Brisbane

and I have a great and continuing fondness for that institution. Earlier on though, amongst other universities, I did quite a lot of study through Charles Sturt University

Over the years, I’ve maintained a continuous link with my friends at Charles Sturt University (CSU). Back when we used to run Code Camps for both developers and DBAs, CSU were only too pleased to jump in to help us. From the minute we arrived that first day in Wagga Wagga, I knew it was going to be good. Associate Profession Irfan Altas was an amazing help and remains a friend to this day. I’m always pleased to get to chat to him.

2020-08-16

Power BI: 5 Minutes to "Wow" and for enterprises, what's next?

Power BI is amazing. And it’s starting to appear all over the place. Many enterprises don’t know what to make of it though. Some are scared that it’ll be the “next Access” where stores of uncontrolled data end up all over the organization. Power BI’s mantra of “5 minutes to Wow” is spot on. It’s easy to be impressed. But enterprises are often struggling with “what comes next after that 5 minutes?”

2020-08-07

Fix: Unexpected error in Analysis Services Power Query designer in Visual Studio 2019

I was editing using the Power Query editor in an Analysis Services project, hosted in Visual Studio 2019. When I tried to use “Add column by example”, I received the error shown above:

Unexpected Error

Could not load file or assembly ‘Microsoft.DataIntegration.TransformDataByExample, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad34e35’ or one of its dependencies. The system cannot find the file specified.

The problem is that the assembly had not been deployed with the Analysis Services Designer.

2020-07-16

T-SQL 101: 78 Custom formatting dates and times in SQL Server using FORMAT

In some upcoming posts, I’ll discuss how you can change between data types, but I wanted to show you first, how you can use the FORMAT() function to convert dates and times to strings.

This query asks for the current date and time value formatted as day then month, then (four digit) year. It also includes the desired culture (en-US) which would be used if the format required any culture-specific items, such as the names of months.

2020-07-13

T-SQL 101: 77 Switching timezone offsets in SQL Server T-SQL with SWITCHOFFSET

I mentioned in the last T-SQL post how you could create a datetimeoffset value by combining a datetime2 with an offset. But sometimes you need to switch to a different offset. And that’s what the SWITCHOFFSET() function does:

In this query, I was taking a local time (that had a timezone offset of 11 hours), and switching it to the current time in Seattle (with a -7 hours offset):

2020-07-06

T-SQL 101: 76 Creating datetimeoffset values in SQL Server T-SQL with TODATETIMEOFFSET

It’s great to have SQL Server data types now that handle time zone offsets. Sometimes though, you need to combine a datetime value and an offset to produce one of these new values. That’s what the TODATETIMEOFFSET() function does:

In this example, I’ve taken 28th February 2019 and added a timezone offset of 10 hours to it:

the output data type is datetimeoffset.

The data type of the first value is actually datetime2.

2020-06-29

SQL: Previous SSMS Tips and Tricks Session

One of the more popular things I’ve ever written is my (free) SQL Server Management Studio Tips and Trips eBook.

I’ve had a few people asking why I haven’t done a video on it lately. I’m planning to do a series on it very soon.

In the meantime, here’s a session that I did with Amit and the people from Data Platform Geeks a while back: Tips and Tricks Session

2020-06-25