SQL Server 2012中LEFT OUTER JOIN的SQL语法

前端之家收集整理的这篇文章主要介绍了SQL Server 2012中LEFT OUTER JOIN的SQL语法前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
由于缺少对* =(LEFT OUTER JOIN)运算符的支持,我们遇到了sql Server 2012的问题.

任何人都可以告诉我sql Server 2012的正确语法是什么,以下sqlsql Server 2008上正常工作?

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,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','V') 
    AND t7412.name = user_name() 
ORDER BY t7410.colid ASC
原文链接:https://www.f2er.com/mssql/77916.html

猜你在找的MsSQL相关文章