Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Complex SQL - what would be the best solution?
Message
Information générale
Forum:
ASP.NET
Catégorie:
Bases de données
Versions des environnements
Environment:
C# 3.0
OS:
Windows XP
Network:
Windows 2003 Server
Database:
MS SQL Server
Divers
Thread ID:
01345823
Message ID:
01346091
Vues:
10
>Use a parameter (tinyint) in your query that will show you what you want, That parameter will accept 3 values:
>0 - Inactive
>1 - Active
>2- all
>Then build your where clause that way:
>WHERE (@Parameter = 2 OR IsActive = @Parameter)

Thanks, Borislav. This idea would not work for our particular scenario, but thanks.

My question was more of does it matter in SQL where the condition is placed.

In other words, having IsActive condition in each union is theoretically supposed to be better than having it as the last clause

e.g. which SQL should perform better

select * from (firstPart where IsActive UNION secondPart where IsActive etc.)

versa

select * from (fristPart union ....) where IsActive
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