Paul Stanley
Paul Stanley

Reputation: 2161

Store DbGeography polygons on sql Server 2008 r2 as text

At the moment I have polygons stored in SQL Server 2008 R2 geography column. So that I can work with them in c# I use the Microsoft.SqlServer.Types v11.0.2 nuget package. I have had problems publishing to Windows 7 where it wont install the correct versions of the CLR types. I would like to stop using the CLR types because of the hassles with publishing. Can I use the DbGeography type with c# and store the polygons on SQL Server with a nVarChar type or some other text type?

Upvotes: 1

Views: 196

Answers (1)

Juan Carlos Oropeza
Juan Carlos Oropeza

Reputation: 48187

Maybe you are looking for STAsText

DECLARE @g geometry;
SET @g = geometry::STGeomFromText('LINESTRING(0 0, 2 3)', 0);
SELECT @g.STAsText();

Upvotes: 1

Related Questions