gpt4 book ai didi

SQL Server 2012 中 LEFT OUTER JOIN 的 SQL 语法

转载 作者:行者123 更新时间:2023-12-02 14:30:02 25 4
gpt4 key购买 nike

由于缺乏对 *= (LEFT OUTER JOIN) 运算符的支持,我们在使用 SQL Server 2012 时遇到了问题。

谁能告诉我以下在 SQL Server 2008 上正确运行的 SQL 在 SQL Server 2012 中的正确语法是什么?

SELECT 
t7410.name, t7408.type, t7410.length,
t7410.status, t7410.prec, t7410.scale,
t7409.type
FROM
dbo.syscolumns t7410, dbo.systypes t7408,
dbo.sysobjects t7409, dbo.sysusers t7411,
master.dbo.syslogins t7412
WHERE
t7410.id = t7409.id
AND t7411.uid = t7409.uid
AND t7409.name = 'GENERAL'
AND t7409.type IN ('U', 'S', 'V')
AND t7410.usertype *= t7408.usertype
AND t7412.sid = t7411.sid
AND t7412.name = user_name()
ORDER BY
t7410.colid ASC

最佳答案

为什么不使用 ANSI JOIN 语法来编写此内容:

SELECT t7410.name, t7408.type, t7410.length, 
t7410.status, t7410.prec, t7410.scale,
t7409.type
FROM dbo.syscolumns t7410
INNER JOIN dbo.sysobjects t7409
ON t7410.id = t7409.id
INNER JOIN dbo.sysusers t7411
ON t7411.uid = t7409.uid
INNER JOIN master.dbo.syslogins t7412
ON t7412.sid = t7411.sid
LEFT JOIN dbo.systypes t7408
ON t7410.usertype = t7408.usertype
WHERE t7409.name = 'GENERAL'
AND t7409.type IN ('U', 'S', 'V')
AND t7412.name = user_name()
ORDER BY t7410.colid ASC

关于SQL Server 2012 中 LEFT OUTER JOIN 的 SQL 语法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13482462/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com