slf*_*slf 25 sql sql-server operators
今天,在客户端的生产系统中,我发现了一个包含不熟悉语法的SQL Server查询.在下面的例子中,*=运营商做了什么?我在MSDN上找不到它.查询执行并返回数据.据我所知,自从他们使用SQL Server 2000以来,它一直存在于系统中,但它们现在正在运行2005.
declare @nProduct int
declare @iPricingType int
declare @nMCC int
set @nProduct = 4
set @iPricingType = 2
set @nMCC = 230
--Build SQL for factor matrix
Select distinct
base.uiBase_Price_ID,
base.nNoteRate,
base.sDeliveryOpt,
IsNull(base.nPrice,0) as nPrice,
IsNull(base.nPrice,0) + Isnull(fact.nFactor,0) as nAdjPrice,
base.iProduct_ID,
fact.iPosition as fiPosition,
base.iPosition,
CONVERT(varchar(20), base.dtDate_Updated, 101) + ' ' + CONVERT(varchar(20), base.dtDate_Updated, 108) as 'dtDate_Updated',
fact.nFactor,
fact.nTreasFactor,
product.sProduct_txt ,
pfi.sPFI_Name,
mccprod.nServicing_Fee,
fact.nNoteRate as fNoteRate,
mcc.nLRA_Charge as nLRA
From
tbl_Base_Prices base, tbl_Factors fact, tbl_Product product, tbl_PFI pfi, tbl_MCC mcc, tbl_MCC_Product mccprod
Where
base.iProduct_ID = @nProduct
And base.iProduct_ID *= fact.iProduct_ID
And base.iPosition *= fact.iPosition
And base.nNoteRate *= fact.nNoteRate
And base.iPricing_Type = @iPricingType
And fact.iMCC_ID = @nMCC
And fact.iProduct_ID = @nProduct
And mcc.iMCC_ID = @nMCC
And mcc.iPFI_ID = pfi.iPFI_ID
And mccprod.iMCC_ID = @nMCC
And mccprod.iProduct_ID = @nProduct
And base.iProduct_ID = product.iProduct_ID
and fact.iPricing_Type= @iPricingType
Order By
base.nNoteRate, base.iPosition
Run Code Online (Sandbox Code Playgroud)
HLG*_*GEM 26
立即删除此代码并替换为左连接.此代码并不总是正确解释(有时SQL Server决定它是交叉连接),即使在SQL Server 2000中,因此可能会给出错误的结果!此外,它已被弃用.
我要补充一点,在调整左连接时,你应该删除所有其他隐式连接.自1992年以来,隐式连接语法已经过时,没有任何借口仍然存在于生产代码中.混合隐式和显式连接可能会产生意外结果.
Thi*_*ies 11
它是左外连接,=*是右外连接.
例如以下是平等的;
SELECT * FROM Table1 LEFT OUTER JOIN Table2 ON Table1.ID = Table2.FK_ID
SELECT * FROM Table1, Table2 WHERE Table1.ID *= Table2.FK_ID
Run Code Online (Sandbox Code Playgroud)
外连接(*=和=*)的非ANSI语法位于将在下一版本的SQL中删除的已弃用功能的官方列表中.
下一版本的SQL Server将不支持以下SQL Server数据库引擎功能.请勿在新的开发工作中使用这些功能,并尽快修改当前使用这些功能的应用程序.
| 归档时间: |
|
| 查看次数: |
34295 次 |
| 最近记录: |