SP help

  • I am getting a error message when executing the SP below:

    Msg 245, Level 16, State 1, Procedure eusp_e5_eSM_AS01_MaterialStockRecordReportNew, Line 33

    Conversion failed when converting the nvarchar value 'H-00001, H-00003' to data type int.

    CREATE PROCEDURE [dbo].[eusp_e5_eSM_AS01_MaterialStockRecordReportNew]

    @MaterialItemContainerCode nvarchar(1000),

    @HCodes nvarchar(1000) OUTPUT

    AS

    DECLARE @MaterialCode nvarchar(1000)

    SELECT @MaterialCode = materialItemCode FROM local_MaterialsItemsContainers MIC

    INNER JOIN local_MaterialsItems MI

    ON (MIC.materialItemIncId = MI.materialItemIncId AND MIC.materialItemSqlId = MI.materialItemSqlId AND MI.isDeleted=0x0)

    WHERE charindex(MIC.materialItemContainerCode,'MC-00000030-13-0001')<>0

    declare @value nvarchar(1000)

    set @value = ''

    select @value = @value + LH.hazardCode + ', ' from Local_MaterialsItems MI

    INNER JOIN Local_MaterialsItemsHazards MIH

    on MI.materialItemIncId = MIH.materialItemIncId AND MI.materialItemSqlId = MIH.materialItemSqlId

    INNER JOIN Local_Hazards LH

    on MIH.hazardIncId = LH.hazardIncId AND MIH.hazardSqlId = LH.hazardSqlId

    where charindex(MI.materialItemCode,@MaterialCode)<>0

    select @HCodes = substring(@value, 1, len(@value)-1)

    RETURN CAST(@HCodes AS nvarchar(1000))

    ----RETURN @HCodes

    ----EXEC eusp_e5_eSM_AS01_MaterialStockRecordReportNew 'MC-00000002-13-0001',''

    The execute script is:

    EXEC eusp_e5_eSM_AS01_MaterialStockRecordReportNew 'MC-00000002-13-0001',''

  • What is the datatype of LH.hazardCode column ?

    Jonathan Bernardez Bernardez
    ___________________________________________________________
    DBD. MCSA SQL Server 2012

  • nvarchar(100) is the datatype used.

  • Try to isolate the error. Run this code out of the stored procedure and debug it to see where is the problem.

    Jonathan Bernardez Bernardez
    ___________________________________________________________
    DBD. MCSA SQL Server 2012

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply