locked
Learning Spacial Aggregate - help debugging RRS feed

  • Question

  • I am going through a tutorial where we are learning about spacial aggregates.  I have this sample code and I am getting an error and I cannot figure out what is wrong with its syntax.  I'm using SQL SErvier Management Studio on 2112 Express

    Here is the code, including the create database:

    CREATE DATABASE Geotable;
    GO

    --Setup table variable for ConvexHullAggregate example
    DECLARE @Geom TABLE
    (
    shape Geometry, 
    shapetype nvarchar(50)
    )
    --Put some data into the table
    INSERT INTO @Geom( SHAPE, SHAPETYPE) 
    VALUES( 'CURVEPOLYGON( CIRCULARSTRNG(2 3, 4 1, 6 3, 4 5, 2 3))','Circrle'),
     ( 'POLYGON(( 1 1, 4 1, 4 5, 1 5, 1 1 ) )', 'Rectagle');

    -- Perform ConvexHullAggregate on @Geom.shape column
    SELECT geometry::ConvexHullAggregate(shape).ToString()
    FROM @Geom; 

    I'm getting hung up on inserting of the values.  Here is the exception message:

    Msg 6522, Level 16, State 1, Line 7
    A .NET Framework error occurred during execution of user-defined routine or aggregate "geometry": 
    System.FormatException: 24142: Expected "(" at position 14. The input has "C".
    System.FormatException: 
       at Microsoft.SqlServer.Types.WellKnownTextReader.RecognizeToken(Char token)
       at Microsoft.SqlServer.Types.WellKnownTextReader.ParseLineStringText()
       at Microsoft.SqlServer.Types.WellKnownTextReader.ParseRingText(Int32 i)
       at Microsoft.SqlServer.Types.WellKnownTextReader.ParseCurvePolygonText()
       at Microsoft.SqlServer.Types.WellKnownTextReader.ParseTaggedText(OpenGisType type)
       at Microsoft.SqlServer.Types.WellKnownTextReader.Read(OpenGisType type, Int32 srid)
       at Microsoft.SqlServer.Types.SqlGeometry.GeometryFromText(OpenGisType type, SqlChars text, Int32 srid)
    .
    The statement has been terminated.

    Any ides what I'm doing wrong?

    Saturday, September 19, 2015 1:16 PM

Answers

  • The error message points out that the error is in your well-known text at position 14. It's a typo, CIRCULARSTRNG is misspelled; it should be CIRCULARSTRING with an I.

    Cheers, Bob

    • Marked as answer by DVDMike Saturday, September 19, 2015 4:03 PM
    Saturday, September 19, 2015 3:59 PM