varchar issue

  • i am getting following exception while attempting to set a alphanumeric value to varchar variable... what would be the reason?... cant i have number at the end of varchar variable?... we cant blame user if he enter number at end of a varchar variable?... any help pls

    @PVC_APPLICATION_NAMEVARCHAR(50)

    SET @PVC_APPLICATION_NAME='APPLICATION NAME1 '

    Conversion failed when converting the varchar value 'APPLICATION NAME1 ' to data type int.

  • You have to use DECLARE statement in order to declare a variable. I tried this

    DECLARE @PVC_APPLICATION_NAME VARCHAR(50)

    SET @PVC_APPLICATION_NAME='APPLICATION NAME1 '

    PRINT @PVC_APPLICATION_NAME

    and it showed me as result: "APPLICATION NAME1 "

    Regards,

    Iulian

  • Please check what type of variable u have declared for @PVC_APPLICATION_NAME.

    I think u have declared as INT....

  • DECLARE @PVC_LOGIN_USERVARCHAR(40),

    @PVC_APPLICATION_IDVARCHAR(40),--yet to finish

    @PVC_PROGRAM_NAMEVARCHAR(40),

    @PI_RET_STATUSINT,

    @PVC_RET_MSGVARCHAR(500),

    @PI_RET_ERRORNUMINT,

    @PVC_APPLICATION_NAMEVARCHAR(50), @pvc_dest int;

    my declaration is mentioned above

  • MonsterRocks (10/26/2010)


    DECLARE @PVC_LOGIN_USERVARCHAR(40),

    @PVC_APPLICATION_IDVARCHAR(40),--yet to finish

    @PVC_PROGRAM_NAMEVARCHAR(40),

    @PI_RET_STATUSINT,

    @PVC_RET_MSGVARCHAR(500),

    @PI_RET_ERRORNUMINT,

    @PVC_APPLICATION_NAMEVARCHAR(50), @pvc_dest int;

    my declaration is mentioned above

    As per the declaration above, I dont see any errors while executing the below code:

    DECLARE @PVC_LOGIN_USER VARCHAR(40),

    @PVC_APPLICATION_ID VARCHAR(40), --yet to finish

    @PVC_PROGRAM_NAME VARCHAR(40),

    @PI_RET_STATUS INT,

    @PVC_RET_MSG VARCHAR(500),

    @PI_RET_ERRORNUM INT,

    @PVC_APPLICATION_NAME VARCHAR(50),

    @pvc_dest int ;

    SET @PVC_APPLICATION_NAME = 'APPLICATION NAME1 '

    PRINT @PVC_APPLICATION_NAME

    Thanks

  • The statements that you provided appear to be correct. Are you sure that the set command is getting the error? Could you be assigning the PVC_APPLICATION_NAME variable to an int variable or column later in the code?

Viewing 6 posts - 1 through 5 (of 5 total)

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