今日、クライアントの運用システム内で、わかりやすい構文を含むSQL Serverクエリが見つかりました。以下の例では、*=
オペレータは何をしていますか?私はそれについて何の言及も見つけられなかったon MSDN。クエリが実行され、データが返されます。彼らは、SQL Server 2000を使用していたので、限り誰でも知っているように、これはシステムにされているが、彼らは今、2005年SQL Server * = Operator?
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
'このコードは常に正しく解釈されるわけではありません(SQL ServerはSQL Server 2000でもクロス結合と判断することがあります)ので、間違った結果が得られます。私はこれがとても古かったことを知っていますが、あなたはこの声明を支持する文書があるかどうか疑問に思っていましたか?ありがとう! – swasheck
* [SQL 2000 BOL:外部ジョインの使用](http://msdn.microsoft.com)から、時々、従来のTransact-SQL外部ジョインに起因するあいまいさの影響を受けないため、SQL-92構文を推奨します。 /en-us/library/aa213228(v=sql.80).aspx)。そのトピックの新しいバージョンでは、 '* ='と '= *'の結合については言及していません。 –
また、(thanks @MikaelEriksson):*この構文を外部結合に使用すると、あいまいな解釈の可能性があるため、非標準的なために使用しないでください。代わりに、FROM句で結合を指定します。* [SQL 2000 BOL:SELECT](http://msdn.microsoft.com/en-us/library/aa259187(v=sql.80).aspx)から。 –