I have an SQL table containing multipolygons (country borders) in varchar(max) format.
I want to convert them into geography format so that I can intersect them with geographical points (also in geography format).
So far I've tried it like this:
ALTER TABLE dbo.Geoboundaries
ADD [GeoLocation] GEOGRAPHY
INSERT INTO [GeoLocation]
SELECT GEOGRAPHY::STGeomFromText(shapeGeometry,4326)
FROM dbo.Geoboundaries
Unfortunately, I am always getting following error:


That's not valid WKT. The Well-Known-Text format doesn't have an SRID prefix. You'll have to either split the string and extract the parts, or remove the SRID prefix entirely with
REPLACE(shapeGeometry,'SRID=4326;','').If multiple SRIDs are possible, you could extract it as a substring and parse it with
cast(SUBSTRING(shapeGeometry,6,4) as int)If you want to fill
Geolocationin the same row though, you need to use UPDATE, not INSERT.