在将 varchar 值 转换成数据类型 int 时失败。

时间:2014-08-14 13:21:28   收藏:0   阅读:998

写了个存储过程是这样的

create proc [dbo].[GetHotKeys]
(
  @top int,
  @where nvarchar(1000)
)
as
 declare @sqlStr nvarchar(1000)
 if @top<>‘‘
   set @sqlStr=‘select top ‘+cast(@top as varchar(10))+‘ * from  hotkeys ‘+@where
 else
   set  @sqlStr=‘select * from  hotkeys ‘+@where

结果出现错误:在将 varchar 值 ‘select top ‘ 转换成数据类型 int 时失败。

解决办法:set @sqlStr=‘select top ‘+cast(@top as varchar(10))+‘ * from  hotkeys ‘+@where

ok

在将 varchar 值 转换成数据类型 int 时失败。,布布扣,bubuko.com

原文:http://www.cnblogs.com/weixi/p/3912033.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!