yangliu2209

Geometry STUnion using SQL Server 2008r2 and view the geometry data in ArcMap

Discussion created by yangliu2209 on Oct 28, 2013
Latest reply on Nov 1, 2013 by vangelo-esristaff
I am trying to union 254 counties' polygons in to 7 different branches (East, West, North, South, Northwest, South-Central. and Central). I have a state boundary shapefile including 254 counties. I create a stored procedure as following:

CREATE PROCEDURE [dbo].[Branch_Union] (@zone varchar(15))
AS
    
 SET NOCOUNT ON; 
      -- select columns from table and insert into a temporaty table 
      SELECT SHAPE, NewBranch INTO #tempZone FROM  BOUNDARIES_WEB 
      WHERE NewBranch = @zone 
      -- Union county polygons in every defined zones 
      DECLARE @g geometry SELECT @g=shape FROM #tempZone 
      SELECT @g=@g.STUnion(shape)FROM #tempZone 
      SELECT @g AS shape INSERT INTO NewBranchTable (shape, tfsBranch) 
            VALUES ((SELECT @g),@ZONE) 


And then, I create the 'NewBranchTable' to store every inserted value:

CREATE TABLE NewBranchTable 
(OID INT IDENTITY,
 NewBranch nvarchar(15),
 shape geometry) 


Finally, I execute my Stored procedure:

EXEC Branch_Union 'East'
EXEC Branch_Union 'West'
EXEC Branch_Union 'Central'
EXEC Branch_Union 'South'
EXEC Branch_Union 'South-Central'
EXEC Branch_Union 'Northwest'
EXEC Branch_Union 'North' 


All the procedures are running well; however, when I create a database connection and add the 'NewBranchTable' to ArcMap, error message pops up and shows that "Could not add the specified data object to the map. Invalid entity type." Could any one can give some advise that what the issue is? Thanks
[ATTACH=CONFIG]28660[/ATTACH]

Attachments

Outcomes