Optional query parameters in SQL Server -


i want fetch data sql server database using values dropdown list.

my query

select  age,city,state,caste,incomemin,incomemax ruser (age between '" + drplistagemin.selecteditem + "' , '" + drplistagemax.selecteditem + "')  , (religion= '" + drplistreligion.selecteditem + "')  "); 

what need understand how build query if value of religion dropdown optional rather compulsory?

in notation of @pratik:

select age,city,state,caste,incomemin,incomemax ruser age between @minage , @maxage , religion = coalesce(@religion, religion); 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -