I am trying to Insert data into a SQL table, only if the data does not currently exist. The issue comes in, from what i have found when a Null is passed in.
I can get the C# SqlCommand to work when all values are present, the moment i add a Null i get an issue, the issue being it upload's the same line again.
using (SqlCommand cmd = new SqlCommand("BEGIN IF NOT EXISTS (SELECT * FROM dbo.tb_someTable WHERE someProperty = '@someProperty') Begin Insert into tb_someTable (someProperty) Values (@someProperty) END END",conn))
{
CheckNullorEmpty(cmd,"@someProperty",someProperty);
cmd.ExecuteNonQuery();
}
The expected output is I only want a new record Inserted if a previous one does not exist.