日期:2014-05-17  浏览次数:20537 次

数据导入与导出。
SQL code
create database db1

use db1

GO
CREATE TABLE table1(
tid int not null,
tname varchar(50) not null,
tvalue varchar(50) not null)

GO
CREATE TABLE table2(
tid int not null,
tname varchar(50) not null)

GO
insert table2(tid,tname)
select 1,'数据1' union
select 2,'数据2' union
select 3,'数据3'



以上是一个模拟数据库,现在需要把table2的数据导入到table1里来,并给tvalue一个默认值。

在线等...





------解决方案--------------------

insert into table1
select tid ,tname ,'默认值' as tvalue
from table2
------解决方案--------------------
SQL code
insert into table1 select *,'你的默认值' from table2