Problem with sql case statement
Posted on 2011-04-26
Can someone show me the proper way to use the case statement in this example?
EXEC MedscribeSQL.dbo.usp_PatientDemographicsUpdate @FName, @MName, @LName, @DOB, @SSNum, @SEX, @HPhone,
WHEN @CreditCode = null THEN @OriginalCreditCode
END as CreditCode,
@Org, @ChartNum, @Dec, @Addr1, @Addr2, @City, @State, @Zip, @Race, 1,
For creditcode I'm basically wanting to use the originalvalue if the new value is null.
The editor says incorrect syntax near CASE and same for AS at the end of the CASE statement.
Is there a better way to do this perhaps?