lundi 15 juillet 2019

Conditionally select data from column decision

I am trying to select PatientID, FirstName, LastName, and TreatmentCode from the Patient table IF the TreatmentCode is not NULL. I keep getting this message:

Msg 207, Level 16, State 1, Line 1 Invalid column name 'TreatmentCode'.

Here's my current query:

IF (TreatmentCode != NULL)
    BEGIN
       SELECT PatientID,
              FirstName,
              LastName,
              TreatmentCode
       FROM sqldb.dbo.Patient
    END

Aucun commentaire:

Enregistrer un commentaire