Tuesday 30 July 2013

Check Null Value in SQL Server 2005

Below SQL Query is used to Check null Value in SQL Server 2005.

Syntax

IFNULL(ColumnName,0)

Example

select (case when ISNULL((Select sum(Amount) From Payment B Where B.Purchase_RefID=Purchase.Purchase_RefID  and Status in('Active')),'0') <>'0' THEN  (Select  sum(Amount)  From Payment B Where B.Purchase_RefID=Purchase.Purchase_RefID  and Status in('Active')) else '0' end ) as PaidAmount

Designing a Sub Report inside RDLC Report

  1. Create Report 1 , this is your main report.
  2. Create Report 2 , this will act as subreport.
  3. Now open report 1 and from toolbox drag the subreport control to this main report.
  4. Then Right click on the subreport control and configure it to Point to the Report 2.
  5. Configure the Parameter For subreport , if you have to pass any paramter.

SQL SERVER – CASE Statement/Expression Examples



CASE expressions can be used in SQL anywhere an expression can be used. Example of where CASE expressions can be used include in the SELECT list, WHERE clauses, HAVING clauses, IN lists, DELETE and UPDATE statements, and inside of built-in functions.

Syntax:
CASE expression
WHEN expression1 THEN expression1
[[WHEN expression2 THEN expression2] [...]]
[ELSE expressionN]
END

Example:
DECLARE @Test INT
SET
@Test = 3
SELECT
CASE @Test
WHEN 1 THEN 'First'
WHEN 2 THEN 'Second'
WHEN 3 THEN 'Third'
ELSE 'Other'
END

Check NULL Value in RDLC Report Viewer and Set Value as ' 0 '



In The Report viewer select table fields and select Expression of Table fields

and Write Expression as Follows


=IIf(IsNothing(Fields!TextBox1.Value),"0",Fields!TextBox1.Value)