'.' 附近的语法不正确- 非常简单的查询
我有一个非常简单的查询,它调用一个用逗号分隔字段的 UDF。查询是
select top 10 * FROM Emails e WHERE EXISTS(SELECT TOP 1 1 FROM dbo.fn_Split(e.committees,','))
当我运行/解析它时,我得到:
Msg 170, Level 15, State 1, Line 4
Line 4: Incorrect syntax near '.'.
我认为它必须与 SQL 2000 有关。如果您将电子委员会切换为硬编码的内容(即“A、B、C、D”),它会起作用美好的。
I have very simple query that calls a UDF which splits a field by comma. The query is
select top 10 * FROM Emails e WHERE EXISTS(SELECT TOP 1 1 FROM dbo.fn_Split(e.committees,','))
When I run/parse it, I get:
Msg 170, Level 15, State 1, Line 4
Line 4: Incorrect syntax near '.'.
I think it must have something to do with SQL 2000. If you switch out e.committees for something hardcoded (i.e., 'A,B,C,D') it works fine.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
SQL 2000 不支持将列名传递给 TVF。这是在 SQL2005 中与 CROSS APPLY 一起引入的,
我不太确定您需要在这里做什么。
e.committees
是非 1NF 数字委员会 ID 列表吗?如果是这样可能会工作,但更好的解决方案是以标准化形式将它们存储在包含
email_id
、committee_id
或其他列的表中。这可能会让您的查询更容易!SQL 2000 doesn't support passing column names to TVFs. That was brought in in SQL2005 along with
CROSS APPLY
I'm not really sure what you are needing to do here. Is
e.committees
a non 1NF list of numeric committee ids? If soMight work but a better solution would be to store these in a normalised form in a table with columns
email_id
,committee_id
or whatever. This will likely make your queries easier!