CREATE proc P_Test--創建存儲過程P_Test
@pageSize int,--每頁數據條數
@pageIndex int,--當前頁數(頁碼)
@pageCount int output,--總的頁數,因為需要顯示頁數,因此是個輸出參數
@Key Nvarchar(100)
as
declare @datacount int--總數據條數
select @datacount=count(*) from [dbo].[Book] where Book_Name Like' "%'+@Key+'%"' or Book_JianJie like '"%' + @Key +'%"' --獲得總數據條數值並賦給參數
set @pageCount=ceiling(1.0*@datacount/@pageSize)--獲得總頁數,並賦給參數
--接下來是獲得指定頁數據
WITH CTE_Search
AS
(
SELECT ,ROW_NUMBER() OVER (ORDER BY Book_Time) AS RowID
FROM Book
WHERE Book_Name Like' "%'+@Key+'%"' or Book_JianJie like '"%' + @Key +'%"'
)
SELECT *
FROM CTE_Search
where RowID between @pageSize(@pageIndex-1)+1 and @pageSize*@pageIndex
過程 P_Test,第 19 行 Incorrect syntax near the keyword 'with'. If this statement is a common table expression, an xmlnamespaces clause or a change tracking context clause, the previous statement must be terminated with a semicolon.
請問大家一下這個問題怎麼解決呢?
WITH CTE_Search改成 ;WITH CTE_Search ,注意多一個;號