sql - Why this Where condition returns 0 Rows? -


select   * tblname mode = '1' , (category = @category or @category = 'all' or newsid = @category) 

i passed @category='all'. returns 0 rows. if or newsid=@category condition not added, query return results

try 1 -

   mode = '1'  ,  (       @category = 'all'      or        @category in (category, cast(newsid varchar(10))) ) 

do not use large data-type length (i mean max):

create table dbo.tbl_contentspage (       newsid int identity(1001,1) not null primary key     , header nvarchar(1024) null     , smallimage image null     , textcontent nvarchar(2048) null     , posteddate datetime not null default(getdate())     , mode varchar(50) null     , [status] varchar(50) null     , category varchar(200) null     , author nvarchar(1024) null     , imgrefid varchar(50) null )  alter procedure [dbo].[spgetarticlepaging] (       @startposition int     , @stopposition int     , @category varchar(200) ) begin      select            newsid         , header         , textcontent         , author         , posteddate         , category         , imgrefid      (         select                newsid             , header             , textcontent             , author             , posteddate             , category             , daterank = row_number() over(order posteddate desc)              , imgrefid          dbo.tbl_contentspage          mode = '1'              ,              (                   @category = 'all'                  or                    @category in (category, cast(newsid varchar(10)))             )     ) t     daterank between @startposition , @stopposition       return 0  end 

Comments

Popular posts from this blog

python - How to create a legend for 3D bar in matplotlib? -

java - Multi-Label Document Classification -

php - Dynamic url re-writing using htaccess -