Link to home
Start Free TrialLog in
Avatar of Rias
RiasFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Where clause in stored procedure

Hello,

 Ihave a where clause in SP ,is a better way of writing this :
WHERE(
					[TravelDate] = @TravelDate OR 
					([TravelDate] is null AND @TravelDate is null) OR
					([TravelDate] is null AND @TravelDate ='') OR
					([TravelDate] ='' AND @TravelDate is null))

Open in new window


Cheers
SOLUTION
Avatar of Barry Cunney
Barry Cunney
Flag of Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Avatar of Vitor Montalvão
Vitor Montalvão
Flag of Switzerland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Rias

ASKER

Cheers!
Avatar of Rias

ASKER

Will there be performance difference if I modify the Stored Procedure with

WHERE ISNULL([TravelDate],'') = ISNULL(@TravelDate,'')

Open in new window

?

Cheers
I don't think so.
How long took the original solution and how long it takes after you used mine suggestion?
Avatar of Rias

ASKER

Can't notice the difference,
Is it worth changing the original code then as I will have to modify nearly 100 Stored Procedures?
I guess TravelDate is not indexed, right?
IMO doesn't worth the work. It's mostly code reduction than performance gain.
Take it as code tuning lesson ;)
Avatar of Rias

ASKER

Cheers!