1. 程式人生 > >匯入資料時 為避免出現重複資料的Sql語句

匯入資料時 為避免出現重複資料的Sql語句

insert into tableName select 
top 1 '劉婷婷1',18
where not exists (select 1 from tableName 
where Age = 18 and Name = '劉婷婷1');

 

inset into 表名 select top 1 (你要插入的資料)

not exists(select 1 from 表名 where 列名=你插入的資料(每一列都這樣寫))