Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
A little SQL brain teaser
Message
From
30/07/2015 03:28:47
 
 
To
29/07/2015 09:35:35
Walter Meester
HoogkarspelNetherlands
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Environment versions
SQL Server:
SQL Server 2005
Application:
Web
Miscellaneous
Thread ID:
01622621
Message ID:
01622676
Views:
47
>I was positive that the 1st would return an error because the query would return 2 records.
>
>I was expecting the 2nd to fail as well for the same reason, but it just picks the last value of the name alphabetically sorted (ascending), just more or less VFP does when SET ENGINEBEHAVIOR is set to 70. Wierd.

Yup, the 2nd one behaves differently than the first. (So Naomi and Sergey were right on, and you were close) :)

I used this example when I taught T-SQL, as an example of querying into scalar values....that the first method was sometimes preferable precisely because a person will get an error. The second (at least IMHO) is worse because it's potentially masking an issue.

Another post coming - I found an interesting quirk with IN that I wasn't aware of until recently.
Previous
Reply
Map
View

Click here to load this message in the networking platform