在表table1中2个字段
list1   list2
  1       1
          5
  3
  4
     7用一条sql语句将list1的3,4 插入到list2列中5和7之间.list2列中没有内容的值为""
谢谢大家啊!

解决方案 »

  1.   

    create table table2(list1 int ,list2 int)
    insert into table2 values(1,1)
    insert into table2 values(null,5)
    insert into table2 values(3,null)
    insert into table2 values(4,null)
    insert into table2 values(null,7)update table2 set list2=list1  where list2 is nullselect * from table2
      

  2.   

    update table1 set list2 = list1 where isnull(list2 ,'') = ''
      

  3.   

    create table #t(list1 int,list2 int)
    insert into #t(list1,list2)
    select 1,1 union all
    select null,5 union all
    select 3,null union all
    select 4,null union all
    select null,7select * from #tupdate #t set list2=list1
    where list2 is nullselect * from #tdrop table #t
      

  4.   

    -------------------
    update table1 set list2=(select list1 from table1 a where list1=3 or list1=4) where list2 is null