I often use the procedure sp_set_firewall_rule to set firewall rules for Azure SQL Server. (There's a similar call to set the firewall for databases). The other day though, I got an error that had me puzzled:
I also tried it with named parameters and got the same error.
When I looked at my previous scripts, I realised that I had used a Unicode string for the first parameter previously.
I changed ‘TestRule’ to N’TestRule’ and it worked fine.
I’ve not seen a procedure before that wants a Unicode string that won’t accept an ASCII string. For example, this works just fine:
Apparently strict data type checking has always been a feature of extended stored procedures and this one checks specifically for a Unicode string. I really don't use extended stored procedures much anyway.
What threw me as well is that I couldn't find it in the list of system stored procedures. It's not there because it's actually an extended stored procedure. These used to mostly have xp prefixes, not sp prefixes, and are a good example of why I don't love using prefixes like that.
I really wish though, that this procedure had a better error message. While the current one is strictly correct, it is not actually all that helpful.