Embedded Google Maps not working with Google App Engine


This one was actually pretty easy to solve, but was interesting anyway.

Developing locally I was OK using http requests for my script files as my local server has now issues with using either http or https for requests. However, App Engine has other ideas. In my scripts file I was including the below reference:


This worked no problem on my machine, but when I published to Google App Engine I saw the below:


Once I changed the script to use HTTPS:


I also needed to add my new site to the list of allowed referrers, by going to the Google Cloud Dashboard > APIs and Services > Selecting my project from the dropdown > clicking Maps Javascript API > Credentials > Editing the credential and adding in a record for my site.

Then I was presented with what I wanted to see:



GCloud SQL – Got an error reading communication packets


I’m writing an app at the moment and to enable users to test the beta version I’ve decided to host the whole shebang on GCloud, Google’s cloud offering.

The whole process is really straight forward to set up, however there doesn’t seem to be a lot of support from the blogging community…. yet.

My app is written in Node.js with Express and a MySQL back end (to make things easier when it comes to reading the data out with Tableau for my reporting developer who won’t be able to understand NoSQL structures).

A couple of things I’ve noticed:

ALL of your require statements need to be the same case as the names of the physical files. So when your app is looking for routes\admin, your folder best be called routes and your file best be called admin, because if they’re called Routes\Admin (note the upper case first letters) your app hosted in Google’s App Engine won’t start. The same goes for your database schema name and all of your stored procedures. So best to use STRICT mode when you’re developing.

The specific error this manifested itself as in Google SQL was:


I’m using PaperChase for logging and saw the real error there:


Because my database is called AAU not aau, I was getting access denied errors. These probably should be can’t find routine errors, but in any case I was able to figure out the problem.

Hopefully it helps you too.

SQL Server – Monitoring a Rollback


Recently bumped into an issue where we needed to kill a large insert, obviously causing SQL Server to perform a rollback. I needed to find out what was going on, so looked to Pinal Dave’s blog post about finding out which queries are running, which you can find here. Which uses the sys.dm_exec_requests and sys.dm_exec_sql_text DMVs.

The below script adds a few little things, to tell you for a given SPID, what the SQL text is that’s being executed and most importantly the expected finish time.

--Set how long you want the script to run for in HH:MM:SS format.
--The longer you leave it running the more accurate it will be
DECLARE @Delay VARCHAR(20)	= '00:00:10';

--Add your SPID, which you can get from sp_who2

DECLARE @StartPercent DECIMAL(18,9), @Statement VARCHAR(MAX), @EndPercent DECIMAL(18,9), @DelaySeconds INT, @PercentToGo DECIMAL(18,9), @Increase DECIMAL(18,9);

--Set the starting percentage complete
SELECT @StartPercent = req.percent_complete, @Statement = sqltext.TEXT
FROM sys.dm_exec_requests req
CROSS APPLY sys.dm_exec_sql_text(sql_handle) AS sqltext
WHERE session_id = @SPID

--Wait for the specified delay time

--Get the end percentage complete
SELECT @EndPercent = req.percent_complete
FROM sys.dm_exec_requests req
WHERE session_id = 206

SET @PercentToGo = 100 - @EndPercent;
SET @Increase = @EndPercent - @StartPercent
SET @DelaySeconds = DATEDIFF(SECOND, 0, @Delay)

--Return the output including the expected finish time
SELECT @SPID [SPID], @Statement [SQLText], @DelaySeconds [DelaySeconds], @StartPercent [StartPercent], @EndPercent [EndPercent], @Increase [Increase], DATEADD(SECOND,(@PercentToGo / @Increase) * @DelaySeconds, GETDATE()) [ExpectedFinishTime]


You can use the same query to monitor the below events (source):


SSAS – Negative total value


We encountered a strange issue when connecting to analysis services through Excel where all of the row level sums were correct, however the total value was a negative, as per below:


As you can see the row level sums are all positives, but the grand total is a negative, why?

The underlying data is all positive, however the underlying datatype in the database is a small int, however there are 6 billion rows in the table.

The issue is that when SSAS sums those 6 billion rows of small int values the total ends up breaking the INT barrier (2,147,483,647) which Excel displays as a negative.

The measure group will inherit its data type from the underlying view and attempt to use that:


To fix this issue you need to alter the data type in the Source and then either leave the DataType in Advanced as Inherit, or change it to BigInt:


Now when you deploy and process your cube, the issue should be resolved!

SSMS – Auto Save is finally here!!


If you haven.t already upgraded to SSMS 2016 you should do immediately. The guys at Microsoft have decoupled SSMS from the SQL Server release cycle and one of the best features by far is the auto-save\recover functionality.

Remember all those times you were putting the finishing touches on the best code you’ve ever written and SSMS crashed? Well worry no more. I did post previously about how SSMSBoost can help you to recover recent sessions, but now SSMS does it out of the box.

When SSMS crashed you’ll be asked to recover recent work and will see something like the below:


All you need to do is connect them back up and viola you’re away!

Of course you could always (and you should always) save your work as soon as you create a new window, but who am I to tell you how to live your life….

SSIS – Unicode data is odd byte size for column 4. Should be even byte size.


This one was interesting and if it wasn’t for a quite obscure article on page 3 of a Google search (who even goes to page 3 anymore) it would have taken me a lot longer to figure out the problem.

Basically we’re hitting a Kafka queue in SSIS to get and process messages as they appear. There’s some info here on how to connect SSIS to Kafka.

The messages that are coming down from the queue are in UTF8 format and I wanted to store them in an NVARCHAR(MAX) column, in case we ever need to process multilingual messages.

As we get the messages down I’m storing them as a string in UTF8, which as per the below isn’t unicode:

string text = Encoding.UTF8.GetString(msg.Payload, 0, msg.Payload.Length);

And then when we push them to the output buffer we’re using UTF8, still not unicode:



The problem came when I tried to push the field into an NVARCHAR(MAX) column in the database, now this IS unicode So we end up getting an error when attempting to push the value from the buffer into the table:

“Unicode data is odd byte size for column 4. Should be even byte size.”

It was an easy fix, just use Unicode as the encoding when you’re pushing the value to the otuput buffer.



This is caused by SQL Server expecting an even number of bytes in an NVARCHAR column as per the below:

“Notice that compressed Unicode strings are always an odd number of bytes. This is how SQL Server determines that the string has actually been compressed, because an uncompressed Unicode string—which needs 2 bytes for each character—will always be an even number of bytes” Source (You’ll need to search for ‘odd’ to find this section..

If nothing else this was an interesting error that I couldn’t find any more info on! So hopefully this helps someone..