我正在使用SQL Server 2008进行生产工作。下面是我的存储过程,它在SQL Server 2012上运行良好,但在SQL Server 2008中会出现抓取错误。原因是fetch
在SQL Server 2008中不可用,但在SQL Server 2012中可用。请帮助我将此脚本转换为适用于SQL Server 2008的版本。
Create PROCEDURE sp_LoadSponsorsListofDonorsforReminder
@pageSize int,
@Offset int,
@TotalRecords int out
as
BEGIN
SELECT max(cd.OID) as OID, max(cd.DonationId) as DonationId,
max(cd.DonorId) as DonorId,
max(Concat(do.FIRSTNAME,' ', do.LASTNAME)) as Donor_Name,
max(do.PHONENUMBER) as PHONENUMBER,
max(do.MOBILENUMBER) as MOBILENUMBER, max(do.ADDRESS) as ADDRESS,
max(do.EMAIL) as EMAIL, max(cd.PaidUpTo) as PaidUpTo,
max(cd.StartDate) as StartDate, max(ca.ChildCode) as ChildCode,
max(concat (ca.FirstName,' ', ca.LastName)) as Child_Name,
max(org.ORGANIZATION_NAME) as Village,
max(d.DonationDate) as DonationDate,
max(r.ReminderOneDate) as ReminderOneDate
FROM child_sponsorship cd
inner join donations d
ON cd.DonationId = d.OID
inner JOIN donor do
ON cd.DonorId = do.OID
inner join child_admission ca
ON cd.ChildId = ca.OID
inner join organization org
ON do.ORGANIZATION = org.OID
left join Reminder_Information r
ON cd.DonorId = r.DonorId
WHERE d.DonationDate < DATEADD(day, -365, GETDATE()) AND
cd.DonorId <> 1174 AND
cd.DonorId <> 1175
GROUP by cd.childId
ORDER By Max(d.DonationDate), max(cd.DonorId) desc
OFFSET @Offset ROWS
FETCH NEXT @pageSize ROWS ONLY
SET @TotalRecords = (select count(*) from child_sponsorship WHERE 1=1);
END;
CONCAT(a, ' ', b) == a + ' ' + b
- Devart