【发布时间】:2019-08-28 20:29:21
【问题描述】:
这是插入代码。
CREATE TRIGGER InsertedPoint
ON Points
instead of insert
AS
insert into Points(Route_Id,Title,Description,Latitude,Longitude,GeoLocation)
SELECT Route_Id,Title,Description,Latitude,Longitude,
geography::STPointFromText('POINT(' + CAST([Latitude] AS VARCHAR(20)) + ' ' + CAST([Longitude] AS VARCHAR(20)) + ')', 4326)
FROM inserted
geography 的赋值问题。当我创建触发器时,我收到错误The column "GeoLocation" cannot be modified because it is either a computed column or is the result of a UNION operator.。我该如何解决问题?
所以它是Points 表
【问题讨论】:
-
GeoLocation是计算列吗?请为表Points显示CREATE TABLE语句好吗? -
是计算列
-
如果 Points.GeoLocation 是计算列,则不要将其添加到插入中。
-
@LukStorms 但我必须插入 GeoLocation。您建议使用什么来代替 Computed 列?
-
我想您可以查看用于该 GeoLocation 列的计算。如果需要,请更改它。但我认为你只能通过 drop & add 列来做到这一点。如果有用的话,也许可以让它持久化。
标签: sql sql-server tsql sql-insert database-trigger