Hi,
I'm new to sql server and I'm using sql server management studio to help me convert some queries for use on sql server 2012 in the form of views. I'm trying to use functions to create some columns in the view, and none of them seem to work properly.
Specifically, this fails:
CASE RecipientID WHEN NULL THEN 0 ELSE 1 End
That results always in 1 being the value of the column. The RecipientID value has some nulls but mostly has values (datatype integer). Every time I try to use case it falls to the 'else' part of the statement for the value, regardless of how simple or complex the options are. I thought about maybe it being some behind the scenes datatype conversion issue?
The IIF statement never works either. Usually it tries to wrap my condition in single quotes and then says it's not a boolean value (error).
Is there some sql server setting that is required to use these logical statements in views? Is there some 'gotcha' that would explain why Case statements always fall to the else? I have tried various references to the data (RecipientID, Mail.RecipientID, dbo.Mail.RecipientID in the example) with no improvement.
Thanks for any direction. I've spent HOURS trying to figure this out.
T
I'm new to sql server and I'm using sql server management studio to help me convert some queries for use on sql server 2012 in the form of views. I'm trying to use functions to create some columns in the view, and none of them seem to work properly.
Specifically, this fails:
CASE RecipientID WHEN NULL THEN 0 ELSE 1 End
That results always in 1 being the value of the column. The RecipientID value has some nulls but mostly has values (datatype integer). Every time I try to use case it falls to the 'else' part of the statement for the value, regardless of how simple or complex the options are. I thought about maybe it being some behind the scenes datatype conversion issue?
The IIF statement never works either. Usually it tries to wrap my condition in single quotes and then says it's not a boolean value (error).
Is there some sql server setting that is required to use these logical statements in views? Is there some 'gotcha' that would explain why Case statements always fall to the else? I have tried various references to the data (RecipientID, Mail.RecipientID, dbo.Mail.RecipientID in the example) with no improvement.
Thanks for any direction. I've spent HOURS trying to figure this out.
T