这是插入代码。
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
表
答案 0 :(得分:4)
您不能在计算列中插入值。计算列的原理是定义一个计算规则,然后RDBMS自动管理它,并根据需要计算其他列的值。
没有这个专栏,您的触发器归结为:
CREATE TRIGGER InsertedPoint
ON Points
INSTEAD OF INSERT
AS
INSERT INTO Points(Route_Id,Title,Description,Latitude,Longitude)
SELECT Route_Id,Title,Description,Latitude,Longitude
FROM inserted
实际上,此触发器是空操作。除非您所做的其他事情没有做,否则最好将其删除。