SQL 2000 到 SQL 2008
我在 SQL 2000 DB 中有一个查询,需要将其迁移到 SQL 2008 DB。它在 SQL2000 中运行良好,我不需要将其修改为 SQL2008。下面是SQL2000中的查询。请指导我如何在 ON 子句中重载 *=
、 =*
子句。
SELECT tblacc. *
FROM tblacc,
tblst,
tblreceipt,
tblrtemp,
tblitem
WHERE tblacc.rkey = tblreceipt.rkey
AND tblacc.stkey = tblst.stkey
AND tblacc.stkey *= tblrtemp.stkey
AND tblacc.stkey *= tblitem.stkey
AND tblacc.itkey *= tblitem.itkey
AND tblrtemp.rkey =* tblreceipt.rkey
I have a query in SQL 2000 DB and I need to migrate it to SQL 2008 DB. It works fine in SQL2000 and I j’t need to revamp it into SQL2008. Below is the query in SQL2000. Please guide me how can we overload *=
, =*
clause in ON clause.
SELECT tblacc. *
FROM tblacc,
tblst,
tblreceipt,
tblrtemp,
tblitem
WHERE tblacc.rkey = tblreceipt.rkey
AND tblacc.stkey = tblst.stkey
AND tblacc.stkey *= tblrtemp.stkey
AND tblacc.stkey *= tblitem.stkey
AND tblacc.itkey *= tblitem.itkey
AND tblrtemp.rkey =* tblreceipt.rkey
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
*= 是左联接
=* 是右联接
您是否尝试过在 SQL Server Management Studio 的 SQL 编辑器中将其显示出来?
它可能会为您转换它。
*= is a left Join
=* is a right Join
Have you tried bringing it up in the SQL Editor in SQL Server Management Studio?
It might convert it for you.
不幸的是,“ON 子句中的重载
*=
,=*
子句”的含义不太清楚。但是,我可以看到一个问题:您正在使用旧式语法进行外连接。您应该将此语法替换为新的“ANSI SQL”语法。这使用关键字而不是*=
和=*
,并将连接条件移至FROM
子句中:WHERE ax *= by
变为FROM a LEFT OUTER JOIN b ON ax = by
WHERE ax =* by
变为FROM a RIGHT OUTER JOIN b ON ax = by
code>旧语法自 SQL Server 2005 以来已被弃用,因为它是非标准的并且容易引入歧义。它不适用于在 SQL Server 中运行的数据库2005 或更高版本 兼容模式,这可能是问题的根源。
It's not quite clear what you mean by "overload
*=
,=*
clause in ON clause", unfortunately. I can see one problem, however: you are using the old-style syntax for outer joins. You should replace this syntax by the new "ANSI SQL" syntax. This uses keywords rather than*=
and=*
, and moves the join condition into theFROM
clause:WHERE a.x *= b.y
becomesFROM a LEFT OUTER JOIN b ON a.x = b.y
WHERE a.x =* b.y
becomesFROM a RIGHT OUTER JOIN b ON a.x = b.y
FROM a FULL OUTER JOIN b ON a.x = b.y
, which pads un-matched tuples from either table with NULLs.The old syntax has been deprecated since SQL Server 2005 because it was non-standard and prone to introducing ambiguity. It is not available on databases running in SQL Server 2005 or later compatibility mode, which is likely the source of your problem.
我相信查询应该如下所示,但我不知道您是否想对表
tblreceipt< 进行
INNER JOIN
和RIGHT JOIN
/代码>。I believe the query should be something like below, though I don't know if you want to do an
INNER JOIN
and aRIGHT JOIN
with the tabletblreceipt
.