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
Post a Comment