Greetings All,
I have an SQL call that I would like to execute in my script. It works fine in the SQL Manager, but PowerBuilder is not happy about it.
PowerBuilder did not like the Declare statement, so I tried moving 'POINT' into the select statement. But I am having trouble figuring out how to escape it.
Not sure if this should be in a stored procedure or if there is some way to embed this in a data window?
Thanks in advance for any help!!
Best, Paul
DECLARE @me geography = 'POINT (13.8 51.3833 4326)';
SELECT TOP(1) country_code, city, latitude, longitude, geography.STDistance(@me) AS distance_meters
FROM city_centers
ORDER BY distance_meters
...or...
SELECT TOP(1) country_code, city, latitude, longitude, geography.STDistance('Point(:place_longitude :place_latitude 4326)') AS distance
As one way, convert the Point DT to string....
DECLARE @g geography;
SET @g = geography::STGeomFromText('LINESTRING(-122.360 47.656, -122.343 47.656)', 4326);
SELECT @g.ToString();
----- Process as a PB String -----
Then convert the string back to a Point data type on the way back (if required)...
https://stackoverflow.com/questions/44048954/convert-string-value-to-geography-data-type-in-sql-server
HTH - Food for thought
Regards ... Chris