Wednesday 15 August 2012

SQL Server 403 Error When Setting a Geography Type for Update -



SQL Server 403 Error When Setting a Geography Type for Update -

all need 1 geography value table , store in table. there logic row take origin table it's not straight select.

in of 50 possible variants of this, error when hitting update target table:

msg 403, level 16, state 1, line 1 invalid operator info type. operator equals not equal to, type equals geography.

my sql looks @ moment:

declare @equipmentid int , @currentlocationid int , @currentgeolocation geography , @lastupdated datetime select @equipmentid = ( select top 1 equipmentid equipment order equipmentid ) select @currentlocationid = (select top 1 equipmentlocationid equipmentlocation equipmentid = @equipmentid order lastupdated desc) select @lastupdated = (select top 1 lastupdated equipmentlocation equipmentid = @equipmentid order lastupdated desc) update dbo.equipment set currentlocationdatetime = @lastupdated , currentgeolocation = (select geolocation equipmentlocation equipmentlocationid = @currentlocationid) , modifiedby = 'system' , modifiedbyuserid = -1 , modifieddate = getdate() equipmentid = @equipmentid

i have had currentgeolocation set in variable of same type, selected same statement see in update.

i have had @currentgeolocation variable populated geography::stgeomfromtext geography::point() function call.

i've used lat , long variables phone call point , fromtext functions.

all same result, above 403 error. understand when concatenating various permutations of geomfromtext function needs known text format point parameter, field value field value killing me, fact error no matter how seek give origin point info target table.

thoughts?

update: i've been experimenting little , found next works fine:

declare @gl geography select @gl = (select geolocation equipmentlocation equipmentlocationid = 25482766) print convert(varchar, @gl.lat) print convert(varchar, @gl.long) update equipment set currentgeolocation = geography::point(@gl.lat, @gl.long, 4326)-- @newgl equipmentid = 10518

but when apply plan original script, i'm same error.

the info in test working off exact same records in original script. original script working off collection of equipmentids, on first one, encounter problem. short test script uses same equipmentlocationid , equipemntid selected values used update first equipment record in collection.

solved!

the error had nil geography type sql reported. pulling items in , out of update statement in effort isolate why still error if save currentgeolocation , update geography, found currentlocationdatetime (datetime, null) culprit. deleted column, added back. problem solved. original script works expected.

don't know happened datetime column caused throw errors against geometry type, it's fixed.

sql sql-server geography

No comments:

Post a Comment