When you use the AsText() function on geometry objects in MSSQL Server 2008+ you get something like this:

"LINESTRING (8.8446177236171337 47.721989356913951, 8.844617919281065 47.721977134398223, 8.844589303417802 47.721976942728766, 8.84454742773029 47.7219801783058, 8.8445167302356325 47.721989634438941, ...)"

The precision of the coordinates is far to great to be useful (for me). For wgs84 coordinates the seventh decimal place is worth ~11 mm. After that, it gets more or less meaningless.

For my workflow I need to put a lot of WKT's in a Textfile. To reduce file size I would like to reduce the coordinate precision to six decimal places.

I could process the textfile and reduce precision in my backend (c#, entity framework) but that seems like a rather costly task.

Is there a way in MSSQL Server to create WKT from geometry objects with a defined number of decimal places?

closed as off-topic by PolyGeo Mar 18 at 7:56

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "When seeking help to debug/write/improve code always provide the desired behavior, a specific problem/error and the shortest code (as formatted text, not pictures) needed to reproduce it in the question body. Providing a clear problem statement and a code attempt helps others to help you." – PolyGeo
If this question can be reworded to fit the rules in the help center, please edit the question.