Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

varchar issue Expand / Collapse
Author
Message
Posted Monday, October 25, 2010 11:44 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Wednesday, October 31, 2012 1:16 AM
Points: 127, Visits: 348
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_NAME VARCHAR(50)

SET @PVC_APPLICATION_NAME='APPLICATION NAME1 '


Conversion failed when converting the varchar value 'APPLICATION NAME1 ' to data type int.
Post #1010538
Posted Tuesday, October 26, 2010 12:01 AM
SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Thursday, June 13, 2013 6:47 AM
Points: 847, Visits: 770
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
Post #1010542
Posted Tuesday, October 26, 2010 12:31 AM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Saturday, April 13, 2013 10:02 AM
Points: 398, Visits: 277
Please check what type of variable u have declared for @PVC_APPLICATION_NAME.
I think u have declared as INT....
Post #1010551
Posted Tuesday, October 26, 2010 12:34 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Wednesday, October 31, 2012 1:16 AM
Points: 127, Visits: 348
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;


my declaration is mentioned above
Post #1010553
Posted Tuesday, October 26, 2010 2:36 AM


SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Wednesday, May 22, 2013 7:11 AM
Points: 877, Visits: 1,159
MonsterRocks (10/26/2010)
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;


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
Post #1010595
Posted Wednesday, October 27, 2010 5:53 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Friday, June 14, 2013 8:16 AM
Points: 2,122, Visits: 1,083
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?
Post #1011434
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse