CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
(图)邪恶的韩国UMPC 使用 Java 编写数据库应用新规范
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  MS-SQL Server >  基础类

将 nvarchar 值 转换为数据类型为 int 的列时发生语法错误。

楼主ceileng888()2006-12-01 16:42:33 在 MS-SQL Server / 基础类 提问

这是我写的存储过程,出错:服务器:   消息   245,级别   16,状态   1,过程   sptable,行   41  
  将   nvarchar   值     转换为数据类型为   int   的列时发生语法错误。  
   
  不知道错在哪里,请各位帮我查查错在哪里。谢谢!我写的存储过程过程  
  水平不高,请帮我在做下优化吧,万分感谢!  
  Create   PROCEDURE   sptable  
  @Identifier   nvarchar(50),  
  @return   nvarchar(50)   OUTPUT  
  as  
  declare   @strtable   as   nvarchar(20)  
  declare   @strtable1   as   nvarchar(20)  
  declare   @strtable2   as   nvarchar(20)  
  declare   @strtable3   as   nvarchar(20)  
  declare   @strtable4   as   nvarchar(20)  
  declare   @ireturn   as   int  
  declare   @ireturn1   as   int  
  declare   @ireturn2   as   int  
  declare   @ireturn3   as   int  
  declare   @ireturn4   as   int  
  select   @ireturn=count(*)   from   dbo.SdaRenewNotify   where   申请编号=@Identifier  
  select   @ireturn1=count(*)   from   dbo.SdaAcceptNotify   where   申请编号=@Identifier  
  select   @ireturn2=count(*)   from   dbo.SdaNotgrantNotify   where   编号=@Identifier  
  select   @ireturn3=count(*)   from   dbo.SdaLocaleNotify   where   申请编号=@Identifier  
  select   @ireturn4=count(*)   from   dbo.SdaSampleNotify   where   申请编号=@Identifier  
  if   @iReturn=1  
        select   @strtable   =   '补正'  
  if   @ireturn1=1  
        select   @strtable1   =   '受理'  
  if   @ireturn2=1  
        select   @strtable2   =   '不予'  
  if   @ireturn3=1  
        select   @strtable3   =   '核查'  
  if   @ireturn4=1  
        select   @strtable4   =   '检验'  
  ProcReturn:  
  select   @return=rtrim(cast(isnull(@strtable,'')   as   nvarchar(20)))+   rtrim(cast(isnull(@strtable1,'')   as   nvarchar(20)))+   rtrim(cast(isnull(@strtable2,'')   as   nvarchar(20)))+   rtrim(cast(isnull(@strtable3,'')   as   nvarchar(20)))+rtrim(cast(isnull(@strtable4,'')   as   nvarchar(20)))  
   
   
  --if   @@error<>0   goto   E_Compile_Fail  
  return   cast(@return   as   nvarchar(20))  
  E_Compile_Fail:  
          declare   @lerror   int  
          select   @lerror   =   @@error  
          RAISERROR   (@lerror,17,127)  
  GO  
  SET   QUOTED_IDENTIFIER   OFF    
  GO  
  SET   ANSI_NULLS   ON    
  GO  
  问题点数:100、回复次数:5Top

1 楼rea1gz(冒牌realgz V0.4)回复于 2006-12-01 16:47:17 得分 0

去掉  
  return   cast(@return   as   nvarchar(20))  
   
  一句  
  Top

2 楼rea1gz(冒牌realgz V0.4)回复于 2006-12-01 16:47:54 得分 0

1楼不对  
  改  
  return   cast(@return   as   nvarchar(20))  
  --〉  
  return    
  Top

3 楼playwarcraft(时间就像乳沟,挤挤还是有的)回复于 2006-12-01 16:48:50 得分 0

欄位:   申请编号     是什麼類型???Top

4 楼rea1gz(冒牌realgz V0.4)回复于 2006-12-01 16:50:06 得分 100

完整  
  Create   PROCEDURE   sptable  
  @Identifier   nvarchar(50),  
  @return   nvarchar(50)   OUTPUT  
  as  
  declare   @strtable   as   nvarchar(20)  
  declare   @strtable1   as   nvarchar(20)  
  declare   @strtable2   as   nvarchar(20)  
  declare   @strtable3   as   nvarchar(20)  
  declare   @strtable4   as   nvarchar(20)  
  declare   @ireturn   as   int  
  declare   @ireturn1   as   int  
  declare   @ireturn2   as   int  
  declare   @ireturn3   as   int  
  declare   @ireturn4   as   int  
  select   @ireturn=count(*)   from   dbo.SdaRenewNotify   where   申请编号=@Identifier  
  select   @ireturn1=count(*)   from   dbo.SdaAcceptNotify   where   申请编号=@Identifier  
  select   @ireturn2=count(*)   from   dbo.SdaNotgrantNotify   where   编号=@Identifier  
  select   @ireturn3=count(*)   from   dbo.SdaLocaleNotify   where   申请编号=@Identifier  
  select   @ireturn4=count(*)   from   dbo.SdaSampleNotify   where   申请编号=@Identifier  
  if   @iReturn=1  
        select   @strtable   =   N'补正'  
  if   @ireturn1=1  
        select   @strtable1   =   N'受理'  
  if   @ireturn2=1  
        select   @strtable2   =   N'不予'  
  if   @ireturn3=1  
        select   @strtable3   =   N'核查'  
  if   @ireturn4=1  
        select   @strtable4   =   N'检验'  
  ProcReturn:  
  select   @return=isnull(@strtable,'')+   isnull(@strtable1,'')+   isnull(@strtable2,'')+   isnull(@strtable3,'')+   isnull(@strtable4,'')  
   
   
  GO  
  Top

5 楼ceileng888()回复于 2006-12-01 16:50:56 得分 0

都是强人啊!给分!Top

相关问题

关键词

得分解答快速导航

  • 帖主:ceileng888
  • rea1gz

相关链接

  • SQL Server类图书

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
惹火投票。。火热进行中...
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
北京创新乐知广告有限公司 版权所有, 京 ICP 证 070598 号
世纪乐知(北京)网络技术有限公司 提供技术支持
Copyright © 2000-2008, CSDN.NET, All Rights Reserved
GongshangLogo