我正在使用sql server 2008進行生產。下面是我在SQL Server 2012上正常工作的存儲過程,但在SQL Server 2008中給出了一個提取錯誤。原因是fetch
不是在SQL Server 2008中構建的,而是在SQL Server 2012中可用。幫助我將此腳本轉換爲使用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(一, '',b)== A + '' + B' – Devart
也取SQL Server 2008中不工作 – Ammar
您需要填充一個臨時表與IDENTITY_column和使用SELECT的組合TOP [@pageSize] ..並使用IDENTITY_column> [@Offset]。在WHERE子句 –