Press "Enter" to skip to content

Category: Error Handling

Troubleshooting the Automation of a Process

Reitse Eskens tells a tale of woe:

When I got the job to restore a bacpac file, I didn’t think much of it. Because it’s quite easy. Get the bacpac and restore it with Azure Data Studio or Sql Server Management Studio. Get coffee, done. Then I got these requirements:

  • The bacpac needs to be downloaded daily from an sFTP server, without certificate
  • The bacpac file is in a zip file
  • The zip file is password protected
  • Everything must be done serverless (Azure Automation, Logic App, Function App, Data Factory and/or Synapse Analytics)
  • It’s a daily process that needs to be done without human supervision

Welcome to cloud development: Part A is easy, Part B is easy, Part C is mildly challenging, and combining A with B and C is a total nightmare because it turns out that A and B aren’t compatible, so by the end, you’re dealing with A” and b and D (because C, C’, C”, etc. wouldn’t work and c and c’ would work but had severe limitations preventing you from using it in this scenario).

Comments closed

SSMS and the Default Web Browser

Erin Stellato explains why things have to be so difficult:

If you have installed SQL Server Management Studio 19.1 or higher and encountered an Internet Explorer dialog with the message “Can’t reach this page” when trying to login using Microsoft Entra authentication (previously known as Azure Active Directory authentication), this post is for you.  An example of what this error looks like is below.  If you haven’t encountered this error and have no issues invoking a web browser from SSMS, then you can stop here and move on to something else!  But if you’re interested, feel free to keep reading.

I think the decision that the tools team made here is the right one: default to using the system browser, but you can see the kind of problems that can cause some environments. It’s hard to write a tool intended to work in a large variety of environments, including highly secured ones.

Comments closed

Resource Governor and Azure SQL Managed Instance

Kendra Little has a note for us:

In Azure SQL Managed Instance, you get to use Resource Governor, even in the General Purpose tier. This is awesome.

Just make sure you execute commands in the context of the master database, or you’ll get error 40510: Statement 'ALTER RESOURCE GOVERNOR' is not supported in this version of SQL Server.

Read on for more information about this error and how to circumvent it.

Comments closed

Debugging Stored Procedures

Erik Darling shares some tips:

Debugging, like error handling, is a design choice that is fairly easy to make at the outset of writing a stored procedure, and is usually a lot easier to get in there if you do it from the get-go.

The number of times I’ve had to go back and add debugging into something only to introduce debugging bugs is actually a bit tragic.

If you’ve never brought down a system with your monitoring process or introduced bugs via debugging code, you’re not living life to its fullest.

Comments closed

Error Handling in T-SQL Stored Procedures

Erik Darling intimates that some of our code might occasionally have errors or might experience circumstances in which not everything is in perfect alignment:

Okay, look, the best post about this is, of course, by Erland Sommarskog: Error and Transaction Handling in SQL Server

Just like Erland, it has three parts and three appendices. If you want to learn how to do a whole lot of things right, give yourself a couple days to read through and digest all that.

What I’m here to talk about is some of the stuff you should think about before implementing any error handling at all.

I agree with most of Erik’s opinion here. My very mild disagreement is that I’ll still protect against things like invalid parameters or logic errors (start date before end date) in the stored procedure. I do that for three reasons:

  • Defense in depth isn’t just a security principle–it’s also a code practices principle.
  • The app gets things wrong, too. Sometimes, the app dev accidentally sends parameters in the wrong order, and it’s better to get an error early on in development versus thinking everything works because the procedure called successfully and ship it.
  • Even if “the” app correctly handles inputs, there’s always a chance some other app or process will call this stored procedure and it might not have the same error handling code built in.
Comments closed

Failure Writing Backups to Azure Blob Storage Due to Limits Reached

David Fowler hits a wall:

Picture this, you’re happily backing up your database to a Azure blob storage until suddenly it starts mysteriously failing with the error…

Write to backup block blob device https://****** failed. Device has reached its limit of allowed blocks.

What’s going on, nothing’s changed?!

Read on to learn the cause of this issue as well as three ways to fix it.

Comments closed

When an Update Doesn’t Update

Aaron Bertrand offers some troubleshooting advice:

Tell me if you’ve heard this one before:

I changed data from my application, but when I checked the database, I couldn’t see the change!

I’ve seen this. Loads. It can be quite perplexing for folks because they expect to see an error message if the insert, update, or delete failed. I put this post together to provide some things you can investigate if this happens to you – you are sure that you updated the data, but when you check using SQL Server Management Studio (SSMS), your change isn’t there. For the remainder of the post, I’m going to use the word “update” to mean any change to the data, even MERGE {shudder}.

Read on for three major classes of reason. One bonus reason: you left the transaction open. Most application frameworks will close transactions after a statement, but if you’re hand-writing transaction logic in your app, forgetting a COMMIT can happen.

Comments closed

Failed to Update Replica Status Due to Exception 35222

Sean Gallardy troubleshoots a problem:

Read Scale Availability Groups can be pretty useful in the right places and for the right things and were a latest feature update for AGs until Contained AGs came along in 2022. Read Scale AGs don’t integrate with clustering of any type and they behave somewhat as mirroring used to where there is no real coordination of resources and it is up to the administrators to make the proper judgement calls or automate whatever possible scenarios they deem important.

Read on to see what this error means and why it’s less of a problem than it first appears.

Comments closed

Azure Database for MySQL Flex Server and Power BI

Denny Cherry dips a toe into unfamiliar waters:

Recently, I upgraded our core Azure SQL Database for MySQL Single Server to Azure SQL Database for MySQL Flex Server. The migration was pretty straight forward and I simply did an export with mysqldump and then an import with MySQL. The problem came up when I tried to use Power BI (PBI) and connect to to the Azure SQL Database for MySQL Flex Server instead. When I tried to connect PBI to the Flex server I kept getting “The given key was not present in the dictionary”.

Read on to see what Denny did to resolve the issue.

Comments closed

Displaying End-User-Defined Characters (EUDC) in SSMS

James Ferebee notes a problem:

A customer opened an interesting case stating SQL Server Management Studio (SSMS) would not display EUDC (End-User-Defined Characters) properly. More information on EUDC can be found here: End-User-Defined and Private Use Area Characters. 

After testing, it was identified by default, both SQL Server Management Studio and Visual Studio encountered this problem. In contrast, Notepad.exe displayed the desired character as intended. A shared aspect of SSMS and VS is the use of Windows Presentation Foundation (WPF).

Read on to see an example of how to create an EUDC and the workaround. I’d never even heard of EUDCs before, and the steps involved to get it to work probably explains why.

Comments closed