convert to sql2008 geometry

Oct 10, 2009 at 5:31 AM


when I convert .shp file to sql  type of  [WKB_Geometry] column is image ,how can I convert it to sql2008 geometry type to get query on it???? and

how can I get the point clicked (x,y) in demo sample in  ajax.aspx.cs?

thank you.

Oct 10, 2009 at 2:09 PM

Hi sa_84,  To convert to SqlGeometry you need to create a new Column in your table e.g

ALTER TABLE [schemaname].[tablename]
ADD [Geom] Geometry

then you can do (this assumes the database has mssqlspatial installed - mssqlspatial stores wkb with extra info):

UPDATE [schemaname].[columnname]
SET [Geom] = geometry::STGeomFromWKB(ST.AsBinary(WKB_Geometry), ST.Srid(WKB_Geometry))

or (if the database does not have mssqlspatial installed and WKB_Geometry is OGC standard):

DECLARE @epsgcode
SET @epsgcode = 4326 /* update to the correct epsg code for your data */

UPDATE [schemaname].[tablename]
SET [Geom] = geometry::STGeomFromWKB([WKB_Geometry], @epsgcode)

hth jd

Oct 11, 2009 at 7:27 AM
Edited Oct 11, 2009 at 10:15 AM


Thank you for your help .