如何保留计算的 GEOMETRY 或 GEOGRAPHY 列

发布于 2024-07-08 12:02:34 字数 703 浏览 8 评论 0原文

我正在尝试在 SQL Server 2008 下创建一个表,其中包含 GEOMETRY 列及其计算的变体。

考虑下表,其中计算列返回缓冲几何图形:

CREATE TABLE [dbo].[Test] (
    [Geometry]      GEOMETRY    NOT NULL,
    [Buffer]        FLOAT       NOT NULL,
    [BufferedGeometry] AS ([Geometry].STBuffer([Buffer])) PERSISTED
);

这样做的问题是它会导致以下错误:

消息 4994,级别 16,状态 1,第 2 行 计算列“BufferedGeometry” 表“测试”无法持久化 因为列类型“几何”, 是非字节顺序的 CLR 类型。

我搜索了 BOL 和网络,似乎找不到解决我的问题的方法。 我真的希望它能够被持久化,这样我就可以有效地对其进行索引。 我可以在代码中设置它,但随后我可能会出现数据不一致的情况,因为我在某个时间点需要这两个值。

有人玩过这个并知道解决方案或解决方法吗?

更新:Microsoft 在 SQL Server 2012 中添加了此功能。

I'm trying to create a table under SQL Server 2008 containing a GEOMETRY column and a calculated variation thereof.

Considering the following table where the calculated column returns a buffered geometry:

CREATE TABLE [dbo].[Test] (
    [Geometry]      GEOMETRY    NOT NULL,
    [Buffer]        FLOAT       NOT NULL,
    [BufferedGeometry] AS ([Geometry].STBuffer([Buffer])) PERSISTED
);

The problem with this is it results in the following error:

Msg 4994, Level 16, State 1, Line 2
Computed column 'BufferedGeometry' in
table 'Test' cannot be persisted
because the column type, 'geometry',
is a non-byte-ordered CLR type.

I have search BOL and the web and can't seem to find a solution to my problem. I really would like it to be persisted so I can index it effectively. I could set it in code, but then I have the possibility of inconsistent data as I require both values at some point in time.

Anyone played with this and know a solution or workaround?

Update: Microsoft has added this functionality in SQL Server 2012.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

装迷糊 2024-07-15 12:02:34

我想你可以使用触发器来计算它并将其存储到 [BufferedGeometry] 字段

I guess you could use a trigger to calculate it and store it to the [BufferedGeometry] field

吻泪 2024-07-15 12:02:34

谁仍然遇到这样的问题:SQL Server 2012 现在允许它

Whoever is still having such problem: SQL Server 2012 now allows it

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文