• I found in other forums that "cross apply" only works if the compatibility_level is greater than 80.

    When I checked the compatibility_level of our database, it's 80.

    SELECT compatibility_level

    FROM sys.databases WHERE name = 'database_name'

    I think Eugene's solution works in greater compatibility-level but I don't have permission to change it.

    Thanks once again Eugene !:-)