views:

237

answers:

4

According to MSDN BOL (Books Online) description on SOME | ANY (Transact-SQL),

SOME and ANY are equivalent.

It does make sense to use either SOME | ANY to make a query more readable.

But is that the only reason why there are 2 keywords in TSQL where they serve the exactly the same purpose?

Are there any historic reasons why they have the same functionality?

A: 

SOME and ANY are equivalent. ANY is ANSI syntax. Why SOME is introduced, I do not know. Could be because of readability, but both of next two sentences are easy to understand.

WHERE 5000 < ANY(SELECT Price FROM dbo.items)
WHERE 5000 < SOME(SELECT Price FROM dbo.items)

Although, SQL server will in both cases execute:

WHERE EXISTS(SELECT * FROM dbo.items WHERE price>5000)

which is also very easy to understand.

Niikola
Hi, Niikola: "Why SOME is introduced, I do not know". and that is the kind of point of this question.
Sung Meister
+2  A: 

SOME and ANY are equivalent in the SQL-92 standard, so while it doesn't answer your question to point that out, it does indicate that the history goes back a long way.

Steve Kass
+2  A: 

From the ANSI-92 SQL Standard (search for "SOME"). Also here, text

<some> ::= SOME | ANY

I suspect the reason is that SQL language comes from the early 1970s, but had no standard until 1986. The standard would have taken elements of the existing SQL dialects, so we have this SOME/ANY anomaly.

A recent SQLServerPedia article explains some differences: "ALL, ANY, and SOME: The Three Stooges"

gbn
@gbn I really enjoyed "ALL, ANY, and SOME: The Three Stooges" article. Thanks.
Sung Meister
+1  A: 

Remember that some database products have been around for almost three decades. Vendors such as Oracle, IBM and Microsoft have always included features in their products which have subsequently been incorporated into the ANSI standard.

Sometimes these features had been developed by several vendors independently, so either the standard or the vendor had to support synonyms for keywords. For instance Oracle had SELECT DISTINCT long before ANSI specified SELECT UNIQUE. Oracle supports both usages.

I don't know whether a similar scenario applies in the case of SOME and ANY. But it seems likely.

APC