易截截图软件、单文件、免安装、纯绿色、仅160KB

如果写递归sql语句 - MS-SQL Server / 应用实例

有两个同样的表结构 
表结构如下:
  id(序号) parentid (父结点序号) name(结点名称)
 表1 记录 1 0 aaa
  2 0 bbb
  3 1 ccc

  。。。。。。
表2 记录  
  1 0 bbb
  2 0 xxx

  。。。。
表1与表2都是树状结构记录。现需要将表1记录导入到表2中 ,表2中已经有部分记录,有些记录与表1中记录相同。
现需要将表1中的记录导入到表2中,需要判断表2中没有表1记录的需要全部导入,并且树状结构和表1中的结构一致。

用存储过程也可以。谢谢。


 
  
 
MRAK 回去再看

顶下



SQL code:


insert into 表2
select * from 表1 a where not exists
(select 1 from 表2 b where a.id=b.id and a.parentid=b.parentid and a.name=b.name)



引用
SQL codeinsertinto 表2select*from 表1 awherenotexists
(select1from 表2 bwhere a.id=b.idand a.parentid=b.parentidand a.name=b.name)

可以尝试

哦 效率啊效率

原来这样真的可以。。想了。没


相关问答:

csv文件转换成sql导入到数据库,没有数据为何?

执行的顺序:
1)文件浏览框(选择文件使用)
选择好文件后
点击一个导入按钮的时候 ,把上面上传框里的csv文件以一个ID为文件名,上传到**/**文件夹下
2)读取这个文件夹下的csv的文件,转换成sql
3 ......

求一SQL - MS-SQL Server / 基础类

表如下
教室ID 座位数 开始时间 结束时间 2009年1月1日 2009年1月2日 2009年1月3日
  101 50 08:00 08:30 30 40 50  
  101 50 09:00 ......

jsp链接sql2000的疑问?



type Exception report


message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jas ......

sql更新字段路径

如果用sql语句更改lj字段的路径,如下:
lj
7/200781616183095962.jar
8/f_200812111413292.jar
8/f_200812111413291.jar

得到的结果如下:
lj
1/7/200781616183095962.jar
1/8/f_20081 ......

求一个sql文的写法

一张表table字段F1和F2

F1    F2
1    a                               
2    ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号