首页 > 代码库 > SQLSever插入空间数据

SQLSever插入空间数据

IF OBJECT_ID ( ‘dbo.SpatialTable‘, ‘U‘ ) IS NOT NULL  
    DROP TABLE dbo.SpatialTable; 
GO 

CREATE TABLE SpatialTable  
    ( id int IDENTITY (1,1), 
    GeomCol1 geometry,  
    GeomCol2 AS GeomCol1.STAsText() ); 
GO 

INSERT INTO SpatialTable (GeomCol1) 
VALUES (geometry::STGeomFromText(‘LINESTRING (100 100, 20 180, 180 180)‘, 0)); 

INSERT INTO SpatialTable (GeomCol1) 
VALUES (geometry::STGeomFromText(‘POLYGON ((0 0, 150 0, 150 150, 0 150, 0 0))‘, 0)); 
GO 

SQLSever插入空间数据