Reputation: 81
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
Upvotes: 0
Views: 25
Reputation: 175586
You could use WHERE
:
SELECT PatientID,
FirstName,
LastName,
TreatmentCode
FROM sqldb.dbo.Patient
WHERE TreatmentCode IS NOT NULL
Upvotes: 2