将MSSQL查询转换为MySQL时出错

时间:2017-03-08 04:44:18

标签: mysql sql-server

有人可以帮我纠正这种转换吗?

原文:

  SET ANSI_NULLS ON
  GO
  SET QUOTED_IDENTIFIER ON
  GO
  -- =============================================
  CREATE PROCEDURE [dbo].[GetCustomersPageWise]
  @PageIndex INT = 1
  ,@PageSize INT = 10
  ,@RecordCount INT OUTPUT
  AS
  BEGIN
  SET NOCOUNT ON;
  SELECT ROW_NUMBER() OVER
  (
      ORDER BY [CustomerID] ASC
  )AS RowNumber
  ,[CustomerID]
  ,[CompanyName]
  ,[ContactName]
  ,[City]
  ,[Country]
  ,[Phone]
  ,[Fax]
  ,[PostalCode]
  INTO #Results
  FROM [Customers]

  SELECT @RecordCount = COUNT(*)
  FROM #Results

  SELECT * FROM #Results
  WHERE RowNumber BETWEEN(@PageIndex -1) * @PageSize + 1 AND(((@PageIndex      -1) * @PageSize + 1) + @PageSize) - 1

DROP TABLE #Results
END

已转换:

 /* SET ANSI_NULLS ON */

/* SET QUOTED_IDENTIFIER ON */

-- =============================================
DELIMITER //

CREATE PROCEDURE GetCustomersPageWise (
p_PageIndex INT /* = 1 */
,p_PageSize INT /* = 10 */
,p_RecordCount INT )
BEGIN
SELECT ROW_NUMBER() OVER;
(
     ORDER BY `CustomerID` ASC
)AS RowNumber
,`CustomerID`
,`CompanyName`
,`ContactName`
,`City`
,`Country`
,`Phone`
,`Fax`
,`PostalCode`
INTO #Results
FROM `Customers`

SELECT COUNT(*) INTO p_RecordCount
FROM #Results;

SELECT * FROM #Results
WHERE RowNumber BETWEEN(p_PageIndex -1) * p_PageSize + 1     AND(((p_PageIndex -1) * p_PageSize + 1) + p_PageSize) - 1;

DROP TABLE #Results
END;
//

DELIMITER ;

错误:

  

MYSQL错误:#1064 - 您的SQL语法出错;检查与您的MariaDB服务器版本对应的手册,以便在'ORDER BY`CustomerID`ASC附近使用正确的语法   )AS RowNumber
  `CustomerID`
  ,第8行的'Com'

0 个答案:

没有答案