sql server - SQL where clause not getting filtered -


i have following query, not giving regard in p.created_by =@searchby clause, how correct results filtered according @searchby too.

alter proc [dbo].[rptcashcollectionouter] @branchid int,                                            @searchby int,                                            @strdate  datetime=null,                                            @enddate  datetime=null     begin        select distinct p.created_on paid_date          reading re               join billing_gen bg on re.id = bg.reading_id               join customer_registration cr on bg.account_number = cr.account_number               join payment p on bg.bill_number = p.bill_number               join customer_category cc on cr.customer_category_id = cc.id         p.created_by = @searchby               , ( ( @strdate null )                      or cast(floor(cast(p.created_on float)) datetime) >=                         cast(floor(cast(@strdate float)) datetime) )               , ( ( @enddate null )                      or cast(floor(cast(p.created_on float)) datetime) <=                         cast(floor(cast(@enddate float)) datetime) )               , cr.branch_id = @branchid        order  p.created_on asc;    end;  

check value inside procedure below.

select @branchid, @searchby, @strdate,@enddate 

and, try run sql manually same value. also, make sure have data in table criteria.

also, trying here ?

cast(floor(cast(p.created_on float)) datetime) 

Comments

Popular posts from this blog

java - Andrioid studio start fail: Fatal error initializing 'null' -

android - Gradle sync Error:Configuration with name 'default' not found -

StringGrid issue in Delphi XE8 firemonkey mobile app -