Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Complex SQL - what would be the best solution?
Message
General information
Forum:
ASP.NET
Category:
Databases
Environment versions
Environment:
C# 3.0
OS:
Windows XP
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01345823
Message ID:
01346091
Views:
9
>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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform