Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Fine tuning a SPROC
Message
 
 
À
21/06/2007 19:50:41
John Baird
Coatesville, Pennsylvanie, États-Unis
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Autre
Versions des environnements
SQL Server:
SQL Server 2000
Divers
Thread ID:
01234693
Message ID:
01234900
Vues:
16
>>>UNION will filter the duplicate records, BUT you will never have ones, because of CAST('' AS char(50))
>>>
>>>
>>>SELECT 1, 'abracadabra'
>>>UNION
>>>SELECT 1, ''
>>>
>>>will generate two records
>>
>>I see now, you're right. We do need a left join in the second portion with is null in where clause.
>
>Ergo your original assertion is false, which is exactly what I figured.

Nope, it is still correct. Every left join is equal to inner join + union for the rest. You can use NOT EXISTS and the same query as at the top or use CTE in SQL Server 2005. There was an interesting discussion in tek-tips forum on a similar problem, but I'm not going to search for it right now.
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform