I want to use case construct of SQL:
CASE WHEN ans='A' THEN 1 ELSE 0 END
(Where ans
is a string declared in ASP.NET) in an insert query like:
SqlCommand AnsCmd = new SqlCommand("insert into answers(ans_desc,istrue)values('" + ans1_desc + "',CASE WHEN ans='A' THEN 1 ELSE 0 END)", conn);
But it is not working... maybe the syntax is wrong? Please help.