Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
rajasekhar857
Constraint Violating Yak Guru
396 Posts |
Posted - 2009-12-13 : 03:50:46
|
| IF(@MENARCH_AGE!=NULL and @MENARCH_AGE='') begin SELECT @Y= ezEMRxID FROM EMRIDS WHERE PROPERTY_NAME='FR_EXAM_ANS_ID' Update EMRIDS set ezEMRxID=@Y+1 WHERE PROPERTY_NAME='FR_EXAM_ANS_ID' SET @idValue = ISNULL(Rtrim(CAST(@Pre_hj as Varchar)),'') + ISNULL(Rtrim(Cast(@Y as varchar)),'') INSERT INTO EMRFRExamAns(FR_EXAM_ANS_ID,FR_EXAM_DATA_ID,QUES_ID,QUES_ANS_ID,CTRL_VALUE,DISP_LABEL) VALUES(@idValue,@xy ,1001,1001,@MENARCH_AGE,'Age') SET @idValue = '' end endin that insert statemet @menarch_age is not working as if not null vales are also there it is not giving.wahat needs to be replaced there |
|
|
russell
Pyro-ma-ni-yak
5072 Posts |
Posted - 2009-12-13 : 10:20:58
|
| this line:IF(@MENARCH_AGE!=NULL and @MENARCH_AGE='')is basically saying if @MENARCH_AGE = '', so you can't expect a value, other than an empty string.also, a NULL comparison is performed with IS and IS NOT, not =, !=so when checking for a NULL value it'sIF @MENARCH_AGE IS NOT NULLfinally, it looks to me like @MENARCH_AGE should be a numeric type. if that's true, make it so, and then no need to check for an empty string either |
 |
|
|
|
|
|
|
|