Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Query Not Working
Message
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Miscellaneous
Thread ID:
01400408
Message ID:
01400432
Views:
33
This is George's answer on this problem:

--------------------------------------------------
This happens because the 2nd version will not return rows where the data is null.

Declare @Temp Table(Data Int)

Insert Into @Temp Values(NULL)
Insert Into @Temp Values(1)
Insert Into @Temp Values(2)

Declare @Search Int

Set @Search = NULL

Select * From @Temp Where (@Search Is NULL Or Data = @Search)

Select * From @Temp Where Data = IsNull(@Search, Data)


The second query will return 2 rows instead of 3.
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform