Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am very new to MS SQL 2008. I got a task to select a polygon from the polygon layer by giving the X-Y coordinates. I already got the script for PostgreSQL for the same thing, but i need it for MS SQL 2008. the code in PostgreSQL is,

SELECT * FROM "Kar_bbmp_198" WHERE ST_Within ((ST_GeomFromText('POINT(773824 1442012)',32643)), the_geom) = TRUE;

Can anybody help me from this, thanks in advance

share|improve this question
Is your data stored in the GEOMETRY or GEOGRAPHY data type? – CatchingMonkey Jul 25 '12 at 8:40
may i know, is any difference will be there if the data stored in Geometry or Geography. Actually i dont know about the storage of data.. – kishor Jul 25 '12 at 8:48
up vote 1 down vote accepted
[TABLES_SPATIAL_COLUMN].STIntersects(GEOGRAPHY::STGeomFromText('POINT(773824 1442012)',[SRID - e.g. 4326])) = 1

You can change the GEOGRAPHY:: to GEOMETRY:: depending on the data type you are using. Also, you could also use .STWithin(), .STContain() to do this.

share|improve this answer
Thank u very much....Now i will try. – kishor Jul 25 '12 at 8:55

ASPMapper probably has the right approach, but I think you do not want STIntersects (that would imply that the point is on the boundary) or STWithin (which would imply that the polygon is within the point). STContains is probably what you need.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.