SQL server 2000中有一个数据表table1,结构如下
Name date1 date2 Length
aaa 2006-1-1 2006-1-2 15
bbb 2006-5-5 2006-7-8 12
.....现有一份Excell数据表,格式如下
Name date1 date2
ccc 2006-1-1 2006-1-2
ddd 2006-5-5 2006-7-8
.....
现在如何将Excell表导入SQL server2000, 如果MSSQL原来的表中的记录有与Excell中Name相同的,就用Excell替换掉,如果不相同就添加到数据库中
Name date1 date2 Length
aaa 2006-1-1 2006-1-2 15
bbb 2006-5-5 2006-7-8 12
.....现有一份Excell数据表,格式如下
Name date1 date2
ccc 2006-1-1 2006-1-2
ddd 2006-5-5 2006-7-8
.....
现在如何将Excell表导入SQL server2000, 如果MSSQL原来的表中的记录有与Excell中Name相同的,就用Excell替换掉,如果不相同就添加到数据库中
然后再判断.
update table1
set name = table2.name
from table1,table2
where table1.date1 = table2.date1 and table1.date2 = table2.date22、insert(这里长度怎么搞?)
insert into table1(name,date1,date2) select a.name,a.date1,a.date2 from table2 a, table1 b where a.date1 <> b.date1 or a.date2 <> b.date2