Create custom shapes by dissolving polygons
Dissolving process allows you to take a group of existing shapes and dissolve the internal boundaries of those polygons. The results a custom boundary the size and shape of the combined source boundaries.
The UnionAggregate() function groups the polygons and removes the internal boundaries. Because it aggregates the polygon, a GROUP BY clause must be used.
Note the #tt1. This sets up a temporary table on the SQL Server. This makes it easy if combining it with the Polyline Encoded Converter since your Polyline Encoded script can then reference #tt1 in the from statement, similar to a Qlik RESIDENT table.
In the example below, a custom 'Cluster' boundary is being created.
select cluster, geometry::UnionAggregate(geom) as geom into #tt1 from qm_shapes.dbo."Clusters_FY17" c inner join qm_shapes.dbo.unsimplified_zip z on (c.Zip = z.zip) group by cluster;