Posts

Showing posts from July, 2011

How to apply CASE in Query

If you want to apply some checks in query then best option is to use Cases. example of case is below: Select Building.ID,Building.Name, case when Building.Status='Completed' or Building.Status='Renovate' then Building.Size else 0  end as 'BuildingSize' It will check for building status and return Building size if building status is completed or renovate and return 0 when the above condition is not satisfied.

For displaying all the selected values of multi value parameter in SSRS report

If you want to display all selected values for multi value parameters in SSRS report then you have to use this function: =Join(Parameters!ParameterName.Label, ",") "This will display all selected values for a parameter but  comma seperated" =Join(Parameters!ParameterName.Label, VBCRLF)    "This will display all selected values for a parameter but  every value on a new line" Now its up to you which function you use.

For converting date-time to only date

If you want to convert date-time to date only in sql query then you use the following function: for example you have 2 parameters ''StartDate" and "EndDate"  firse declare them... ----------------------------------------------------------------------------------- @StartDate datetime, @EndDate datetime SELECT  * where  tablename.Startdate >=convert(varchar, @StartDate, 102) and tablename.enddate <=convert(varchar, @EndDate, 102) ----------------------------------------------------------------------------------- ************************** Explanation ************************** @StartDate datetime = Declaration of parameter StartDate @EndDate datetime = Declaration of parameter EndDate convert(varchar, @StartDate, 102)  = function of converting date-time to date  tablename.Startdate >=convert(varchar, @StartDate, 102) = Proper syntax of function