Question : check if an NTEXT field is empty

I have the following stored procedure which works Fine.

It is , as you can see used to count some stats.  What I need is to count another column (ChildPolicy   ntext) but I want to count only if the field is NOT empty.



ALTER PROCEDURE sp_QueryStats_ChildProtection
(
      @StartDate      varchar(20),
      @EndDate                      varchar(20)
)
AS
SELECT
Sum(Case When ChildLegislation = 1 Then 1 Else 0 End) AS Legisislation,
Sum(Case When ChildConsultancy = 1 Then 1 Else 0 End) AS Consultancy,
Sum(Case When ChildPOCNI = 1 Then 1 Else 0 End) AS POCNI,
Sum(Case When ChildKeepingSafe = 1 Then 1 Else 0 End) AS KeepingSafe,
Sum(Case When ChildAccrediation = 1 Then 1 Else 0 End) AS Accrediation,


Sum(Case When ChildQuery = 1 Then 1 Else 0 End) AS Total


FROM TBL_Queries
INNER JOIN TBL_PolicyPracticeTraining ON TBL_Queries.QueryId = TBL_PolicyPracticeTraining.QueryID

WHERE      QueryDate >= CONVERT(varchar(20),@Startdate,112)  AND QueryDate <= CONVERT(varchar(20),@EndDate,112)

Answer : check if an NTEXT field is empty

Sum(Case When ChildPolicy IS NULL then 0 when substring(ChildPolicy,1, 100) = '' then 0 else 1 End) ,
Random Solutions  
 
programming4us programming4us