F1表Val列,F2表Val列想写到biao1的liouliang1列和liouliang2列里面去.不过写以前要吧biao1的liouliang1列和liouliang2列的数据先清空

解决方案 »

  1.   

    update biao1 set liouliang1=null,liouliang2=null
    update biao1 
    set 
        liouliang1=F1.Val,
        liouliang2=F2.Val
    from 
        F1,F2 
    where 
        ... --表与表之间的关联关系
      

  2.   

    where 
        ... --表与表之间的关联关系
    天啊,这里怎么写啊?
      

  3.   

    update biao1 set liouliang1=null,liouliang2=null
    update biao1 
    set 
        liouliang1=F1.Val,
        liouliang2=F2.Val
    from 
        F1,F2 
    这么写还是把最后一个数值写到所有行里面啦
      

  4.   

    表与表之间的关联关系指将f1,f2的两个val列来填充biao1的liulang1和liulang2列时的对应关系,即哪个val1列值对应到哪个liulang1列.
    这个关系只能问你自己.
      

  5.   

    哦,f1的val列biao1的liulang1,f2填充biao1的liulang2列.真对不起大家
      

  6.   

    select identity(int,1,1) id ,val into #temp1 from f1
    select identity(int,1,1) id ,val into #temp2 from f2truncate table biao1insert biao1
    select a.val,b,val
    from #temp1 a,#temp2 b
    where a.id = b.id
      

  7.   

    表F1
    Val
    10794.1953125
    10715.4921875
    10745.171875
    10773.791015625
    10787.8349609375
    10712.3125
    10778.8251953125
    10677.3330078125
    10697.7373046875
    10736.42578125
    10783.0654296875
    10687.1376953125
    10827.0546875
    10832.0888671875
    10803.734375
    10741.7265625
    10796.0498046875
    10738.28125
    10653.21875
    10797.375
    10754.9765625
    10751.53125
    10774.0556640625
    10749.94140625
    8738.6416015625
    8758.515625
    8702.072265625表F2
    Val
    4518.107421875
    4867.72216796875
    4473.05859375
    4871.431640625
    4203.8251953125
    4619.6884765625
    4390.2041015625
    4326.60546875
    4360.34814453125
    5514.6591796875
    5387.8154296875
    5447.52734375
    5261.85546875
    5432.68798828125
    5181.65087890625
    5435.337890625
    5404.5986328125
    5513.95263671875
    5322.98046875
    5442.93408203125
    5228.11279296875
    5324.923828125
    5335.876953125
    5341.353515625
    5356.36962890625
    5134.65869140625
    3270.34204101563
    表:表biao1
    liouliang1
    10794.1953125
    10715.4921875
    10745.171875
    10773.791015625
    10787.8349609375
    10712.3125
    10778.8251953125
    10677.3330078125
    10697.7373046875
    10736.42578125
    10783.0654296875
    10687.1376953125
    10827.0546875
    10832.0888671875
    10803.734375
    10741.7265625
    10796.0498046875
    10738.28125
    10653.21875
    10797.375
    10754.9765625
    10751.53125
    10774.0556640625
    10749.94140625
    8738.6416015625
    8758.515625
    8702.072265625liouliang2
    4518.107421875
    4867.72216796875
    4473.05859375
    4871.431640625
    4203.8251953125
    4619.6884765625
    4390.2041015625
    4326.60546875
    4360.34814453125
    5514.6591796875
    5387.8154296875
    5447.52734375
    5261.85546875
    5432.68798828125
    5181.65087890625
    5435.337890625
    5404.5986328125
    5513.95263671875
    5322.98046875
    5442.93408203125
    5228.11279296875
    5324.923828125
    5335.876953125
    5341.353515625
    5356.36962890625
    5134.65869140625
    3270.34204101563
    就是这样就可以啦
      

  8.   

    shuiniu(飞扬的梦)(我是一头只吃西红柿的水牛) ( ) 信誉:100    Blog  2006-09-15 10:42:00  得分: 0  
     
     
       不会,是这样吧!!!
    ---------------------------------楼主心中没有对应关系,很可能如你所说,按顺序填上去就可以了.
      
     
      

  9.   

    select identity(int,1,1) id ,val into #temp1 from f1
    select identity(int,1,1) id ,val into #temp2 from f2truncate table biao1insert biao1
    select f1.val,f2.val
    from #temp1 f1,#temp2 f2
    where f1.id =f2.id服务器: 消息 213,级别 16,状态 4,行 6
    插入错误: 列名或所提供值的数目与表定义不匹配。
      

  10.   

    select identity(int,1,1) id ,val into val from f1
    select identity(int,1,1) id ,val into val from f2truncate table biao1insert biao1
    select f1.val,f2.val
    from val f1,val f2
    where f1.id =f2.id
    服务器: 消息 2714,级别 16,状态 6,行 2
    数据库中已存在名为 'val' 的对象。
      

  11.   

    biao1如果不仅仅有liuliang1,liuliang2这两个列,那么不能 truncate table biao1
    你仅仅是要清这二列.
    当按顺序将val1,val2填充到 biao1的二个列上时,也存在一个对应关系.将 
    select *,identity(int) xid into # from biao
    写入临时表然后用 xid与 f1,f2的临时表进行关连,更新临时表 #,再 truncate table biao1,最后将 #中数据写入 biao1.
      

  12.   

    yun ,还没没解决啊,你要什么样的结果贴出来大家看看
      

  13.   

    你想让biao1最后是什么样的结果,贴出来看看
      

  14.   

    那随便怎么样都可以
    能把F1表Val列写到biao1的liouliang1列,F2表Val列写到liouliang2列里面去就可以.更新进去也可以,先删除再插入也可以.来个完整的好不好啊.我要疯啦.
      

  15.   

    结果就是
    表:表biao1
    liouliang1                 louliang2
    10794.1953125              4518.107421875          
    10715.4921875              ````````
    10745.171875
    10773.791015625
    10787.8349609375
    10712.3125
    10778.8251953125
    10677.3330078125
    10697.7373046875
    10736.42578125
    10783.0654296875
    10687.1376953125
    10827.0546875
    10832.0888671875
    10803.734375
    10741.7265625
    10796.0498046875
    10738.28125
    10653.21875
    10797.375
    10754.9765625
    10751.53125
    10774.0556640625
    10749.94140625
    8738.6416015625
    8758.515625
    8702.07226562
      

  16.   

    declare @F1 table(id int identity(1,1),Val float)
    insert into @F1 select 
    10794.1953125 union all select 
    10715.4921875 union all  select 
    10745.171875 union all  select 
    10773.791015625 union all  select 
    10787.8349609375 union all  select 
    10712.3125 union all  select 
    10778.8251953125 union all  select 
    10677.3330078125 union all  select 
    10697.7373046875 union all  select 
    10736.42578125 union all  select 
    10783.0654296875 union all  select 
    10687.1376953125 union all select  
    10827.0546875 union all  select 
    10832.0888671875 union all  select 
    10803.734375 union all  select 
    10741.7265625 union all  select 
    10796.0498046875 union all  select 
    10738.28125 union all  select 
    10653.21875 union all select  
    10797.375 union all  select 
    10754.9765625 union all  select 
    10751.53125 union all  select 
    10774.0556640625 union all  select 
    10749.94140625 union all  select 
    8738.6416015625 union all  select 
    8758.515625 union all  select 
    8702.072265625
    declare @F2 table(id int identity(1,1),Val float)
    insert into @F2 select 
    4518.107421875 union all  select 
    4867.72216796875 union all  select 
    4473.05859375 union all  select 
    4871.431640625 union all  select 
    4203.8251953125 union all select  
    4619.6884765625 union all  select 
    4390.2041015625 union all  select 
    4326.60546875 union all  select 
    4360.34814453125 union all  select 
    5514.6591796875 union all  select 
    5387.8154296875 union all  select 
    5447.52734375 union all  select 
    5261.85546875 union all  select 
    5432.68798828125 union all  select 
    5181.65087890625 union all select  
    5435.337890625 union all  select 
    5404.5986328125 union all  select 
    5513.95263671875 union all  select 
    5322.98046875 union all  select 
    5442.93408203125 union all  select 
    5228.11279296875 union all select  
    5324.923828125 union all select  
    5335.876953125 union all  select 
    5341.353515625 union all  select 
    5356.36962890625 union all  select 
    5134.65869140625 union all  select 
    3270.34204101563
    --实际操作中用 insert @F1 select Val from F1 和 insert @F2 select Val from F2,把@biao1 换成你的表名就可以了
    declare @biao1 table(liouliang1 float,liouliang2 float)
    delete from @biao1
    insert into @biao1 
    select a.val,b.val from @F1 a full join @F2 b on a.id=b.id
    select * from @biao1