当前位置: 代码迷 >> Sql Server >> 数据导入与导出。该如何解决
  详细解决方案

数据导入与导出。该如何解决

热度:77   发布时间:2016-04-27 10:47:46.0
数据导入与导出。
SQL code
create database db1use db1GOCREATE TABLE table1(tid int not null,tname varchar(50) not null,tvalue varchar(50) not null)GOCREATE TABLE table2(tid int not null,tname varchar(50) not null)GOinsert table2(tid,tname)select 1,'数据1' unionselect 2,'数据2' unionselect 3,'数据3'



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

在线等...





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

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