asp.net - Insert mutiple unique rows into a table -
I am not familiar with SQL as much as I'm trying to insert multiple rows of data in a table, if No line exists Your code looks right as I wrote it: (changes are only cosmetic.) edit: If performance is an issue, but You can make it a BusinessFilterPhrase duplicate values in the column, do not just insert. I
if (filterCategoryList = null!) {Foreach (KeyValuePair & LT; string, filter the integer & gt; filterCategoryList). {Insert Cmd.CommandText = "tblBusinessName (BusinessFilterPhrase, BusinessCategoryID) selected tblBusinessName as" + "t1 @ BusinessFilterPhrase, @ BusinessCategoryID" + "" + "is not the" + "(select * as d1 from tblBusinessName Where d1.BusinessFilterPhrase = @BusinessFilterPhrase) "; Cmd.Parameters.AddWithValue ("@FilterFilterPhrase", filter.Key); Cmd.Parameters.AddWithValue ("@ BusinessCategoryID", Filters. Value.ToString ()); Cmd.ExecuteNonQuery (); }}
tblBusinessName (BusinessFilterPhrase, BusinessCategoryID) select @BusinessFilterPhrase, putting @BusinessCategoryID does not exist where tblBusinessName t1 (select 1 from tblBusinessName d1 where d1.BusinessFilterPhrase = @BusinessFilterPhrase)
BusinessFilterPhrase create an index :
index idx_tblBusinessName_B on tblBusinessName (BusinessFilterPhrase) Create usinessFilterPhrase;
is index, if you want the database to enforce uniqueness of the column will put duplicate values (if this is an error Will generate).
Comments
Post a Comment