Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CASE NULL value not returning case value

Status
Not open for further replies.

sirnose1

Programmer
Nov 1, 2005
133
US
I have a stored procedure that when executed returns some data and writes it to a temp table. Some of the data returns and empty string. I have implemented a case function to return the word 'NONE' if the value is empty or null. However it does not seem to work. The help will be greatly appreciated. Thanks in advance.

INSERT INTO GPSNameValueTemp (GPSFieldName, GPSFieldValue)
SELECT 'CmsOut_DiagnosisAffectDrgFlag',CASE CONVERT(varchar(1000), XmlData.query('/MC_MedicareCmsOut/CmsOut_DiagnosisAffectDrgFlag/text()'))
WHEN NULL THEN 'NONE'
WHEN '' THEN 'NONE'
ELSE CONVERT(varchar(1000), XmlData.query('/MC_MedicareCmsOut/CmsOut_DiagnosisAffectDrgFlag/text()'))
END
FROM GPS.ProcessedClaimOutput WHERE ProcessedClaimID = @ProcessedClaimID AND GPSType = 3
 
Try:

Code:
CASE CONVERT(varchar(1000), XmlData.query('/MC_MedicareCmsOut/CmsOut_DiagnosisAffectDrgFlag/text()'))
    WHEN '' THEN 'NONE'
    ELSE COALESCE(CONVERT(varchar(1000), XmlData.query('/MC_MedicareCmsOut/CmsOut_DiagnosisAffectDrgFlag/text()')), 'NONE')
END

Hope this helps.

[URL unfurl="true"]http://www.imoveisemexposicao.com.br/imobiliarias-em-guarulhos[/url]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top