grantballantyne
asked on
Must declare the scalar variable @polygon"
Dear Experts
I am trying to run the following SQL Query:
DECLARE @polyline GEOGRAPHY;
SET @polygon = geography::Parse('POLYGON( (47.0 -124.0, 47.0 -122.0,
50.0 -122.0, 50.0 -124.0, 47.0 -124.0))');
SELECT *
from current_residential_geogra phy
where
@polygon.STIntersects(curr ent_reside ntial_geog raphy.GeoL ocation) = 1
However Iam getting the error message "Must declare the scalar variable "@polygon"
Can anyone advise where I am going wrong with the syntax?
Thanks
I am trying to run the following SQL Query:
DECLARE @polyline GEOGRAPHY;
SET @polygon = geography::Parse('POLYGON(
50.0 -122.0, 50.0 -124.0, 47.0 -124.0))');
SELECT *
from current_residential_geogra
where
@polygon.STIntersects(curr
However Iam getting the error message "Must declare the scalar variable "@polygon"
Can anyone advise where I am going wrong with the syntax?
Thanks
DECLARE @polyline GEOGRAPHY;
Shouldn't that be "polygon" and not "polyline"?
In fact you declared for @polyline, and used @polygon in your query.
please change it as @polyline in the Query. that'll do.
please change it as @polyline in the Query. that'll do.
Is GEOGRAPHY a valid SQL Server Data Type !
Hi... I think your declare says @polyline instead of @polygon. Would that fix the issue?
DECLARE @polyline GEOGRAPHY;
SET @polygon = geography::Parse('POLYGON( (47.0 -124.0, 47.0 -122.0,
50.0 -122.0, 50.0 -124.0, 47.0 -124.0))');
SELECT *
from current_residential_geogra phy
where
@polygon.STIntersects(curr ent_reside ntial_geog raphy.GeoL ocation) = 1
DECLARE @polyline GEOGRAPHY;
SET @polygon = geography::Parse('POLYGON(
50.0 -122.0, 50.0 -124.0, 47.0 -124.0))');
SELECT *
from current_residential_geogra
where
@polygon.STIntersects(curr
> Is GEOGRAPHY a valid SQL Server Data Type !
Are you stuck in 2005? Check 2008 books online
Are you stuck in 2005? Check 2008 books online
ASKER
Thanks evryone
I have changed the syntax to:
DECLARE @polygon GEOGRAPHY;
SET @polygon = geography::Parse('POLYGON( (47.0 -124.0, 47.0 -122.0,
50.0 -122.0, 50.0 -124.0, 47.0 -124.0))');
SELECT *
from current_residential_geogra phy
where
@polygon.STIntersects(curr ent_reside ntial_geog raphy.GeoL ocation) = 1
However I am now getting the following error:
Msg 6522, Level 16, State 1, Line 3
A .NET Framework error occurred during execution of user-defined routine or aggregate "geography":
System.FormatException: 24201: Latitude values must be between -90 and 90 degrees.
System.FormatException:
at Microsoft.SqlServer.Types. GeographyV alidator.V alidatePoi nt(Double x, Double y, Nullable`1 z, Nullable`1 m)
at Microsoft.SqlServer.Types. Validator. BeginFigur e(Double x, Double y, Nullable`1 z, Nullable`1 m)
at Microsoft.SqlServer.Types. Forwarding GeoDataSin k.BeginFig ure(Double x, Double y, Nullable`1 z, Nullable`1 m)
at Microsoft.SqlServer.Types. Coordinate ReversingG eoDataSink .BeginFigu re(Double x, Double y, Nullable`1 z, Nullable`1 m)
at Microsoft.SqlServer.Types. OpenGisWkt Reader.Par seLineStri ngText()
at Microsoft.SqlServer.Types. OpenGisWkt Reader.Par sePolygonT ext()
at Microsoft.SqlServer.Types. OpenGisWkt Reader.Par seTaggedTe xt(OpenGis Type type)
at Microsoft.SqlServer.Types. OpenGisWkt Reader.Rea d(OpenGisT ype type, Int32 srid)
at Microsoft.SqlServer.Types. SqlGeograp hy.Geograp hyFromText (OpenGisTy pe type, SqlChars taggedText, Int32 srid)
at Microsoft.SqlServer.Types. SqlGeograp hy.Parse(S qlString s)
Thanks
I have changed the syntax to:
DECLARE @polygon GEOGRAPHY;
SET @polygon = geography::Parse('POLYGON(
50.0 -122.0, 50.0 -124.0, 47.0 -124.0))');
SELECT *
from current_residential_geogra
where
@polygon.STIntersects(curr
However I am now getting the following error:
Msg 6522, Level 16, State 1, Line 3
A .NET Framework error occurred during execution of user-defined routine or aggregate "geography":
System.FormatException: 24201: Latitude values must be between -90 and 90 degrees.
System.FormatException:
at Microsoft.SqlServer.Types.
at Microsoft.SqlServer.Types.
at Microsoft.SqlServer.Types.
at Microsoft.SqlServer.Types.
at Microsoft.SqlServer.Types.
at Microsoft.SqlServer.Types.
at Microsoft.SqlServer.Types.
at Microsoft.SqlServer.Types.
at Microsoft.SqlServer.Types.
at Microsoft.SqlServer.Types.
Thanks
@cyberkiwi
Seems I'm a little behind
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
actually it looks liek you have them inverted
('POLYGON((-124.0 47.0, -122.0 47.0 ...
('POLYGON((-124.0 47.0, -122.0 47.0 ...
SET @polygon = geography::Parse('POLYGON(
50.0 -122.0, 50.0 -124.0, 47.0 -124.0))');
SELECT *
from current_residential_geogra
where
@polygon.STIntersects(curr