Reputation: 137
I'm using DELPHI with ADO and SQL Server 2014.
In our database table there is a spatial column for geometrical data. We can read and write data to this field (more info is here : https://learn.microsoft.com/de-de/sql/relational-databases/spatial/spatial-data-sql-server).
If I display this table using a TDBGRID component I got only (BLOB) shown for the content of this column in my table.
Now I want to see the content of this column. Is the any good coding to show the content of this column e.g. in a dbmemo as text.
The only solution I know is to read the field as text into a string and put this to a normal memo, I'm looking forward to get a more efficient method to access this data
Upvotes: 4
Views: 6095
Reputation: 77
In case your geometry includes Z and / or M values it is better to call .ToString () method.
SELECT MyColumn.ToString () FROM MyTable
The output includes Z and M values in addition to X,Y Coordinates. The .STAsText() method returns only the X,Y coordinates of your shape.
Upvotes: 2
Reputation: 7912
You can query e.g. for Well-known text format by using SQL function like STAsText:
SELECT MyColumn.STAsText() FROM MyTable
An alternative would be fetching your data in Well-known binary data stream with parsing it on the client side to represent as text by yourself (the format is described). For fetching such stream you'd use STAsBinary function:
SELECT MyColumn.STAsBinary() FROM MyTable
Yet another option would be fetching raw geometry data as they are stored in database (as you do right now) and parse it by yourself. The format is described in the [MS-SSCLRT] document. But if I were you I would better write parser for the WKB format and fetch data in WKB format because it's quite established universal format, whilst SQL Server internal formats may change frequently.
Upvotes: 8