is this the same thing? | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

is this the same thing?

WHERE isapproved = 1 OR @isapproved = 0 versus WHERE isapproved= @isapproved any performance considerations?
When @isapproved = 0,
WHERE isapproved = 1 OR @isapproved = 0
will give you every recored regardless of the value in isapproved as your where statement will always be true
WHERE isapproved= @isapproved
will only give u the records where isapproved and @isapproved match So, no, they are not the same Ben ‘I reject your reality and substitute my own’ – Adam Savage
ok so there is no way of getting ONLY the records where isapproved = 0 right?

there is: WHERE isapproved = 0 or SET @isapproved = 0
SELECT ….
FROM…
WHERE isapproved = @isapproved will both do it ‘I reject your reality and substitute my own’ – Adam Savage
quote:Originally posted by SqlPerfNoob ok so there is no way of getting ONLY the records where isapproved = 0 right?

Hi,
Your question itself has the answer,
directly filter by
where isapproved=0 no need of storing it in a variable and then referring to it.
]]>