My table "mytable" in MS SQL Server looks like:
|Id|ka|kb|kc |kd
|1 | 1| 1|NULL|NULL
|2 | 1| 1|1 |NULL
|3 | 1| 1|1 |1
where Id, ka kb can not be null but kc and kd can be null.
Can I select from mytable with variables that also can be null ?
int? varka = 1, varkb = 1, varkc = null, varkd = null;
select Id from mytable where ka = varka and kb = varkb and kc = varkc and kd = varkd
My desired Id from mytable is "1", only "1" but I am getting a NULL in C#, or no result in T-SQL.
is nullto test for nulls. It isn't clear how you are adding the parameters, though, so I can't be clear what you're doing here.