将varchar值'0A'转换为数据类型int时转换失败

时间:2013-10-01 15:38:48

标签: sql-server-2008 stored-procedures

我有一个从Web表单调用的存储过程。直到今天,一切都很好。突然间,我开始收到这条消息:

将varchar值'0A'转换为数据类型int时,转换失败。

我不明白为什么我收到此消息,因为程序一直运行良好到目前为止。

这是存储过程

USE [InvoiceSHC]
GO
/****** Object:  StoredProcedure [dbo].[UpdateSHCInvoice3]    Script Date: 10/01/2013 09:59:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:      Tim Vavra
-- Create date: 6/7/2013
-- Description: This is an update to UpdateSHCInvoice to account for the configuration alt value 
-- when updating simple and complex changes.  This process will also account for whether an entry
-- is correcting a previously incorrect entry.  
-- =============================================
ALTER PROCEDURE [dbo].[UpdateSHCInvoice3] 
    -- Add the parameters for the stored procedure here
    (@Ref nvarchar(50), 
    @PhaseName nvarchar(50),
    @PageType nvarchar(50),
    @Page nvarchar(50),
    @Config nvarchar(50),
    @ChngType nvarchar(50),
    @Correction varchar(10),
    @UserName nvarchar(100),
    @Timestamp datetime


)

AS
BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;
    declare @conval decimal(2,0)
    set @conval = 0

    -- Insert statements for procedure here
    insert into MasterData3 ([Ad],[Phase],[Page Type] , [Page], [Config] , [Change Type],[UserName], [Timestamp], [correction], [conval]) 
                    values(@Ref, @PhaseName , @PageType , @Page , @Config ,@ChngType, @UserName, @Timestamp, @Correction, @conval)

     update MasterData3
        set [page_equivalent]  =
        Case
            When [Page] like '[0-9]' then LEFT([Page],1) 
            When[Page] like '[0-9]-%' then LEFT([Page],1)+(cast(RIGHT([page],2)as int)*.01)+.26 
            When [Page] like '[0-9][A-Z]' then left([Page],1)+((ASCII(convert(varchar,(RIGHT([Page],1))))-64)*.01) 
            When [Page] like '[0-9][A-Z]-%' then left([Page],1)+((ASCII(convert(varchar,(substring([Page],2,1))))-64)*.01)+ (cast(RIGHT([page],2)as int)*.001)
            When [Page] like '[0-9][0-9]' then LEFT([Page],2)
            When[Page] like '[0-9][0-9]-%' then LEFT([Page],2)+(cast(RIGHT([page],2)as int)*.01)+.26 
            When [Page] like '[0-9][0-9][A-Z]' then left([Page],2)+((ASCII(convert(varchar,(RIGHT([Page],1))))-64)*.01) 
            When [Page] like '[0-9][0-9][A-Z]-%' then left([Page],2)+((ASCII(convert(varchar,(substring([Page],3,1))))-64)*.01)+ (cast(RIGHT([page],2)as int)*.001)

        end

    update MasterData3
        set conval = -1 where correction = '1' or correction = 'True'
    update MasterData3
        set conval = 1 where correction = '0' or correction = 'False'
/*  update MasterData3
        set correction = 'False' where correction = '0'
    update MasterData3
        set correction = 'True' where correction = '1'
*/      

END

就像这里的参考一样,是与存储过程中的变量相关的值

@Ref 465612
@PhaseName Release
@Page 09D
@PageType Lip Tab Alt
@Config 17897
@ChngType Version
@Correction False
@UserName tvavra
@Timestamp 10/1/13

我很困惑为什么现在它停止了。我在这个相同的参考文献上有其他条目,它们完美无缺。

非常混乱。

0 个答案:

没有答案