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.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 'null' problem

Author  Topic 

rajasekhar857
Constraint Violating Yak Guru

396 Posts

Posted - 2010-01-22 : 01:43:38
SELECT CODING_FAV_ID ,
'I' AS RECORD_TYPE ,
REFERENCE_ID ,
DIAGNOSIS_CODE AS CODE,
DIAGNOSIS_NAME AS DESCRIPTION
FROM EMRCODINGFAVORITES ECF
INNER JOIN
EMRDIAGNOSISCODESLKUP EDC
ON EDC.DIAGNOSIS_ID = ECF.REFERENCE_ID
WHERE
ECF.STATUS = 1
AND
ECF.RECORD_TYPE = 'I'


hi the above one is my query where reference_is is a varchar data type and null as a character value is inserted and diagnosis_id is a numeric datatype.hoe to handle this as on condition is failing because of 'null'

rajasekhar857
Constraint Violating Yak Guru

396 Posts

Posted - 2010-01-22 : 01:51:44
got it

SELECT CODING_FAV_ID ,
'I' AS RECORD_TYPE ,
REFERENCE_ID ,
DIAGNOSIS_CODE AS CODE,
DIAGNOSIS_NAME AS DESCRIPTION
FROM EMRCODINGFAVORITES ECF
inner join EMRDIAGNOSISCODESLKUP EDC
ON EDC.DIAGNOSIS_ID = ECF.REFERENCE_ID
WHERE ECF.REFERENCE_ID!= 'null'
AND ECF.STATUS = 1
AND ECF.RECORD_TYPE = 'I'


thanks
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2010-01-22 : 01:59:12
"WHERE ECF.REFERENCE_ID!= 'null'"

Yuck! but hopefully you didn't design the database
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-01-25 : 02:48:32
quote:
Originally posted by Kristen

"WHERE ECF.REFERENCE_ID!= 'null'"

Yuck! but hopefully you didn't design the database


SELECT [SELECT] FROM [FROM] WHERE [NULL] IS NOT NULL

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2010-01-25 : 03:59:39
Yeah, when I was at college all the students used to write their code with names like that to annoy the teachers. The teachers had seen it all before of course ...
Go to Top of Page
   

- Advertisement -