特别郁闷2005里写的存储过程怎么解决字符串长度问题?
存储过程内容
ALTER PROCEDURE [dbo].[GetPageDataOutRowPageCount](@PageIndex int = 1,--当前页数 @PageSize int = 4,--每页大小@NowPage int = 1,--根据传入栏目id要加载当前页的数据@RowCount int output,--总行数(传出参数)@PageCount int output--总页数(传出参数))ASbegin DECLARE @sql NVARCHAR(225),@sqlCount NVARCHAR(225) select @RowCount =COUNT(FCaseChildId),@PageCount=CEILING((COUNT(FCaseChildId)+0.0)/@PageSize) FROM TCaseContent where FParentsId=@NowPage SET @sql='SELECT TOP'+str(@PageSize)+' * FROM TCaseContent where FParentsId='+str(@NowPage)+'and FCaseChildId not in(select top '+str((@PageIndex-1)*@PageSize) +' FCaseChildId from TCaseContent where FParentsId='+str(@NowPage)+' order by FImageUpTime desc ) order by FImageUpTime desc' print @sql EXEC(@sql)end
编译器生成的
SELECT TOP 2 * FROM TCaseContent where FParentsId= 3and FCaseChildId not in(select top 2 FCaseChildId from TCaseContent where FParentsId= 3 order by FImageUpTime desc ) order by FImageUpTime d
这一看最后的desc就没了 但是在存储过程里去掉几个空格 语句能正确执行
那么像SELECT TOP 2 这里生成的空格明显多余这可以用LTRIM去掉 长度限制怎么解决?
谢谢
- 1 回答
- 0 关注
- 545 浏览
添加回答
举报
0/150
提交
取消