呵呵,今天晚上弄了一晚上的存储过程,头都大了,怎么弄都成功不了..显示vchar不能转换为int..上网查了好久才发现,原来字符串跟数字型的连接
'+LTRIM(@aa)+'数字型要这样搞哦 ,真是没经验啊..
1 set ANSI_NULLS ON
2 set QUOTED_IDENTIFIER ON
3 GO
4 -- =============================================
5 -- Author: 杨峰
6 -- Create date: 2009-08-22 12:41
7 -- Description: 分页,用到了ROW_NUMBER()
8 -- =============================================
9 ALTER PROCEDURE ShowPage
10
11 @startIndex int = 1 , -- 开始索引
12 @endIndex int = 1 -- 结束索引
13 AS
14 declare @strSQL varchar ( 5000 )
15
16 set @strSQL =
17 ' SELECT * FROM ( ' +
18 ' SELECT ROW_NUMBER() OVER (ORDER BY id) AS RowNumber,
* FROM news ) AS sp WHERE RowNumber BETWEEN
' + LTRIM ( @startIndex ) + ' AND ' + LTRIM ( @endIndex )
20
21 exec ( @strSQL )
22 print @strSQL -- 测试用,可在查询的时候看到生成的SQL语句
'+LTRIM(@aa)+'数字型要这样搞哦 ,真是没经验啊..
1 set ANSI_NULLS ON
2 set QUOTED_IDENTIFIER ON
3 GO
4 -- =============================================
5 -- Author: 杨峰
6 -- Create date: 2009-08-22 12:41
7 -- Description: 分页,用到了ROW_NUMBER()
8 -- =============================================
9 ALTER PROCEDURE ShowPage
10
11 @startIndex int = 1 , -- 开始索引
12 @endIndex int = 1 -- 结束索引
13 AS
14 declare @strSQL varchar ( 5000 )
15
16 set @strSQL =
17 ' SELECT * FROM ( ' +
18 ' SELECT ROW_NUMBER() OVER (ORDER BY id) AS RowNumber,
* FROM news ) AS sp WHERE RowNumber BETWEEN
' + LTRIM ( @startIndex ) + ' AND ' + LTRIM ( @endIndex )
20
21 exec ( @strSQL )
22 print @strSQL -- 测试用,可在查询的时候看到生成的SQL语句