projects log {ts '2025-03-17 13:15:25'} SQL declare @ownerId int = 6868 ; declare @ownerType varchar(3) = 'MFR' ; with projects as ( select p.projectId, p.projectName, p.startDate, p.endDate, nullif( p.projectOwnerUserId, 0 ) projectOwnerUserId, m.firstName + ' ' + m.lastName as projectOwnerFullName from tbl_WRK_Projects p with (nolock) left outer join tbl_FSPRO_Members m with (nolock) on m.ownerId = p.ownerId and m.fsl_tablecode = p.ownerType and m.fspro_userId = p.projectOwnerUserId where p.ownerId = @ownerId and p.ownerType = @ownerType ) , projects_mappedData as ( select * from projects ) , projects_preData as ( select * from projects_mappedData with (nolock) where ( 1 = 1 ) ) , projects_data as ( select * from projects_preData ) , projects_return as ( select * from projects_data where 1 = 1 order by projectName offset 0 rows fetch next 50 rows only ) , projects_result as ( select ( select count(*) from projects_data ) as totalCount, ( select * from projects_return for json auto, include_null_values ) as data ) select * from projects_result for JSON PATH, INCLUDE_NULL_VALUES, WITHOUT_ARRAY_WRAPPER