如有库db1,db2,都有表t,现在将db1中的t中的数据导入到db2中
insert into db2..t(col1,col2...)
select col1,col2... from db1..t如果存在着自动编号id,则:
set identity_insert id on
insert into db2..t(id,col2...)
select id,col2... from db1..t
set identity_insert id off
insert into db2..t(col1,col2...)
select col1,col2... from db1..t如果存在着自动编号id,则:
set identity_insert id on
insert into db2..t(id,col2...)
select id,col2... from db1..t
set identity_insert id off
解决方案 »
- 可以通过sqlserver直接修改mdb文件吗 或者创建空白mdb文件??
- 返回查询一条记录的前10条和后10条记录 包含查询的那条记录的集
- 链接服务器 删除时,提示 提供程序内存不足
- DAO c++
- Error converting data type varchar to numeric -- 怪问题
- 删除重复(估计有点难)
- ASP+SQL查询查询问题--SQL占用很大内存???
- 查询一周第一天和最后一天数据的问题
- 谁有函数求得某年某月第一个星期日是什么日子的?
- SQL Query Analyzer不能启动怎么回事
- 大家分析一下www.csdn.net论坛的数据库设计!
- 请教:创建文档服务器
select col1,col2... from 库名2.所有着2.表名2
如果存在着自动编号id,则:
set identity_insert db2..t on
insert into db2..t(id,col2...)
select id,col2... from db1..t
set identity_insert db2..t off
下面是DTS系统执行时的脚本:
insert bulk [aspnet].[dbo].[TABLE1]("id" char(10) COLLATE Chinese_PRC_CI_AS,"name" char(10) COLLATE Chinese_PRC_CI_AS,"age" char(10) COLLATE Chinese_PRC_CI_AS)with(check_constraints)
insert into 库名1.所有着1.表名1(col1,col2...)
select col1,col2... from 库名2.所有着2.表名2
如上面的 select * from 源数据库名(.dbo.源表)
()内的可以不写吗?
不是省略表名,是省略库名。
select * from 表名