declare @userId int = declare @ownerId int = ; declare @ownerType varchar(3) = ; with data as ( select savedReportId, userReportName, nullif( userReportGroup, '' ) userReportGroup, shared, userId from tbl_SYS_SavedReports with (nolock) where ownerId = @ownerId and ownerType = @ownerType and userId = @userId and temporary = 'N' ) #forJSON( 'data', attributes.datastore, 'userReportName' )#