表A有id,time,name,address
表B有id,time,name
想把A里面 2010-10-10<time<2010-10-20的数据
都插到b里,一次性
谢谢
表B有id,time,name
想把A里面 2010-10-10<time<2010-10-20的数据
都插到b里,一次性
谢谢
解决方案 »
- 求一SQL语句
- tpl文件能用SQL数据库调用吗?
- The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION.报错是什么原因呀!
- 查看图片问题
- 在线急求SQLSERVER2008递归查询方案
- audit logout 时间很长[200分 求解决方案]
- 请问用vb的ado的connection连到sql server 2000,sql server2000最大能同时接受多少个connection的连接?
- 问SQL的问题,一定送分
- 今天我生日,1700分大放送,为增加节日气氛,出一题数据库题目给20分,内容不限先到先得。
- 用什么命令查看ms sql server 2000某个数据表的结构?
- 经纬度这样的数据应该设置成什么数据类型性能最好?
- 一条更新语句
insert into @b(id,time,name)
select id,time,name from @a
where time between '2010-10-10' and '2010-10-20'
insert into 表B(id,time,name)
select id,time,name from 表A
where time between '2010-10-10' and '2010-10-20'上面把表打错了
select id,time,name from 表A
where time between '2010-10-10' and '2010-10-20'
select * from tb1 where id>5id data2
----------- -----------
2 1
3 5
4 4
6 10
7 10
8 10
9 10
10 10
11 17(9 row(s) affected)
insert into 表B(id,time,name)
select id,time,name
from 表A
where '2010-10-10'<time and time<'2010-10-20'-- between '2010-10-10' and '2010-10-20' 相当于'2010-10-10'<=time and time<='2010-10-20'
--time字段是字符型
insert into 表B(id,[time],name)
select id,[time],name from 表A
where convert(varchar(10),[time],120) between '2010-10-10' and '2010-10-20'
假设2
--期间内有500万条记录,基本是不太可能。用如下方式:
--CMD下导出
D:\>bcp "select id,time,name from 表A where time between '2010-10-10' and '2010-10-20'" queryout inserto.dat -T -c--SQL执行导入
BULK INSERT 数据库名.架构名.表B FROM 'D:\inserto.dat'
bcp的where内容调整为假设1的where内容。(忘了修改日期转换)
select id,[time],name from A
where convert(varchar(10),[time],120) between '2010-10-10' and '2010-10-20'---B表中的id是自动编号insert into B([time],name)
select [time],name from A
where convert(varchar(10),[time],120) between '2010-10-10' and '2010-10-20'
insert into B
select id,time,name from A
where time between '2010-10-10' and '2010-10-20'