如何创建指向字段名称中包含句点的 SQL Server 视图的 Jet ODBC 链接?

发布于 2024-07-06 16:51:47 字数 569 浏览 10 评论 0原文

我需要创建从 Access 2003 (Jet) 数据库到 SQL Server 托管视图的 ODBC 链接,该视图包含包含句点的别名字段名称,例如:

Seq.Group

在视图后面的 SQL 源中,字段名称括在方括号中...

SELECT Table._Group AS [Seq.Group]

...所以 SQL Server 不会抱怨创建视图,但是当我尝试从 Jet DB 创建到它的 ODBC 链接(以编程方式或通过 Access 2003 UI)时,我收到错误消息:

“Seq.Group”不是有效名称。 制作 确保其中不包含无效的 字符或标点符号,并且它 不太长。

不幸的是,我无法修改视图的结构,因为它是另一个产品的一部分,所以我坚持使用字段名称。 我可以添加我自己的带有无标点符号字段名称的视图,但我真的宁愿根本不修改 SQL Server,因为这样每次升级、修补程序等都会成为另一个维护点有谁知道更好的解决方法?

I need to create an ODBC link from an Access 2003 (Jet) database to a SQL Server hosted view which contains aliased field names containing periods such as:

Seq.Group

In the SQL source behind the view, the field names are encased in square brackets...

SELECT Table._Group AS [Seq.Group]

...so SQL Server doesn't complain about creating the view, but when I try to create an ODBC link to it from the Jet DB (either programmatically or via the Access 2003 UI) I receive the error message:

'Seq.Group' is not a valid name. Make
sure that it does not include invalid
characters or punctuation and that it
is not too long.

Unfortunately, I cannot modify the structure of the view because it's part of another product, so I am stuck with the field names the way that they are. I could add my own view with punctuation-free field names, but I'd really rather not modify the SQL Server at all because then that becomes another point of maintenance every time there's an upgrade, hotfix, etc. Does anyone know a better workaround?

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

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

发布评论

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

评论(3

怀中猫帐中妖 2024-07-13 16:51:47

虽然从技术上讲我最终没有逃脱这个点,但你的建议实际上确实让我意识到了另一种选择。 当我想知道如何将转义码“传递”到“SQL”服务器时,我突然意识到:为什么不使用“SQL 传递查询”而不是 ODBC 链接表呢? 由于我只需要对 SQL Server 数据进行读取访问,因此它工作得很好! 谢谢!

Although I didn't technically end up escaping the dot, your suggestion actually did make me realize another alternative. While wondering how I would "pass" the escape code to the "SQL" server, it dawned on me: Why not use a "SQL Pass-Through Query" instead of an ODBC linked table? Since I only need read access to the SQL Server data, it works fine! Thanks!

南风几经秋 2024-07-13 16:51:47

只是在这里猜测:您是否尝试转义点? 像“[Seq\.Group]”之类的东西?

Just guessing here: did you try escaping the dot? Something like "[Seq\.Group]"?

那请放手 2024-07-13 16:51:47

另一种建议是在 SQL Server 上添加一个新视图,而不是修改现有视图。 即使您的初始视图是“解决方案”的一部分,也不会阻止您添加新视图:

SELECT Table._Group AS [Seq_Group]

Another proposal would be to add a new view on your sql server, not modifying the existing one. Even if your initial view is part of a "solution", nothing forbids you of adding new views:

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