cast(@pagesize as varchar)
把int性变量都转化一下就可以了
--查看员工列表
create proc User_Get
(
@Line int,--查看类型,离职还是在职
@ShopID int,--查看X店铺里面的所有员工
@startindex int,
@pagesize int,
@Key nvarchar(50),
@Order varchar(50)
)
as
begin
declare @SQL varchar(2000)
set @SQL = 'select top('+@pagesize+') * from User_View where U_Line='+@Line+' And U_ID NOT IN
(
select top('+@startindex*@pagesize+') U_ID from Users where U_Line='+@Line+' order by '+@Order+' desc
) order by '+@Order+' desc'
end
go
改成如下:
--查看员工列表
create proc User_Get
(
@Line int,--查看类型,离职还是在职
@ShopID int,--查看X店铺里面的所有员工
@startindex int,
@pagesize int,
@Key nvarchar(50),
@Order varchar(50)
)
as
begin
declare @SQL varchar(2000)
set @SQL = 'select top('+cast(@pagesize as varchar)+') * from User_View where U_Line='+@Line+' And U_ID NOT IN
(
select top('+cast(@startindex*@pagesize as varchar)+') U_ID from Users where U_Line='+@Line+' order by '+@Order+' desc
) order by '+@Order+' desc'
end
go
- 本文标题: SQL 在将varchar 值转换成数据类型 int 时失败
- 文章分类:【SQLServer】
- 非特殊说明,本文版权归【胡同里的砖头】个人博客 所有,转载请注明出处.