• without more details, all i can offer is an example:

    in this case, I've wrapped the counting sql with another query to get me the isnull of the count.

    SELECT ISNULL(CNT,0) As MatchingRecords FROM

    (SELECT

    COUNT(*) AS CNT

    FROM SYSOBJECTS

    WHERE 1=2 --CONDITION WILL NEVER FIND RECORDS

    ) X

    the other thing to do is to use a SUM and CASE to calculate the count:

    SELECT

    SUM(CASE WHEN xtype IN ('U') THEN 1 ELSE 0 END) AS TableCount,

    SUM(CASE WHEN xtype IN ('V') THEN 1 ELSE 0 END) AS ViewCount,

    SUM(CASE WHEN xtype IN ('P') THEN 1 ELSE 0 END) AS ProcCount,

    SUM(CASE WHEN xtype IN ('FN','TF') THEN 1 ELSE 0 END) AS FuncCount,

    SUM(CASE WHEN xtype IN ('bananas') THEN 1 ELSE 0 END) AS WierdCount --CONDITION WILL NEVER FIND RECORDS

    FROM SYSOBJECTS

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!