当前位置:Gxlcms > mysql > 关于存储过程的。。。

关于存储过程的。。。

时间:2021-07-01 10:21:17 帮助过:28人阅读

USE [jcCmsDb] GO /****** 对象: StoredProcedure [dbo].[up_DataPageRowNumber] 脚本日期: 04/25/2013 20:06:12 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER PROCEDURE[dbo].[up_DataPageRowNumber] @SQL Nvarchar(2000), @Order Nvar

USE [jcCmsDb]
GO
/****** 对象: StoredProcedure [dbo].[up_DataPageRowNumber] 脚本日期: 04/25/2013 20:06:12 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

ALTER PROCEDURE[dbo].[up_DataPageRowNumber]
@SQL Nvarchar(2000),
@Order Nvarchar(40),
@PageIndex int,
@PageSize int,
@TotalRecorder int output
AS
BEGIN
SET NOCOUNT ON;
declare @ExceSQL nvarchar(4000)
declare @start_row_num AS int
SET @start_row_num=(@PageIndex-1)*@PageSize+1
declare @end_row_num int
set @end_row_num=@PageIndex*@PageSize
declare @RowNumber nvarchar(100)
set @RowNumber=',ROW_NUMBER() OVER(ORDER BY '+@Order+')as RowNumber from'
set @SQL=Replace(@SQL,'from',@RowNumber)
set @ExceSQL='select @TotalRecorder=max(RowNumber)from(' +@SQL+ ')as tmp'
execute sp_executesql @ExceSQL,N'@TotalRecorder int output',@TotalRecorder output
set @ExceSQL = 'select*from(' + @SQL + ') as tmp where RowNumber between' +Convert( nvarchar,@start_row_num)
+ 'And' +Convert( nvarchar,@end_row_num)
print @ExceSQL
execute(@ExceSQL)
END

declare @a int
exec up_DataPageRowNumber "select * from jc_Article","Id",2,2,@a output
print @a

为什么会一直抱这个错??抓狂。。。。

select*from(select * ,ROW_NUMBER() OVER(ORDER BY Id)as RowNumber from jc_Article) as tmp where RowNumber between3And4
消息 4145,级别 15,香港服务器租用,状态 1,香港空间,虚拟主机,第 1 行
在应使用条件的上下文(在 'between3And4' 附近)中指定了非布尔类型的表达式。

人气教程排行