Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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
add comment

2 Answers

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
add comment
SELECT * FROM 
[TABLE_NAME]
WHERE 
[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
add comment

Your Answer

 
discard

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.