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
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 插入错误: 列名或所提供值的数目与表定义不匹配。
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' 的对象。
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
update biao1
set
liouliang1=F1.Val,
liouliang2=F2.Val
from
F1,F2
where
... --表与表之间的关联关系
... --表与表之间的关联关系
天啊,这里怎么写啊?
update biao1
set
liouliang1=F1.Val,
liouliang2=F2.Val
from
F1,F2
这么写还是把最后一个数值写到所有行里面啦
这个关系只能问你自己.
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
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
就是这样就可以啦
不会,是这样吧!!!
---------------------------------楼主心中没有对应关系,很可能如你所说,按顺序填上去就可以了.
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
插入错误: 列名或所提供值的数目与表定义不匹配。
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' 的对象。
你仅仅是要清这二列.
当按顺序将val1,val2填充到 biao1的二个列上时,也存在一个对应关系.将
select *,identity(int) xid into # from biao
写入临时表然后用 xid与 f1,f2的临时表进行关连,更新临时表 #,再 truncate table biao1,最后将 #中数据写入 biao1.
能把F1表Val列写到biao1的liouliang1列,F2表Val列写到liouliang2列里面去就可以.更新进去也可以,先删除再插入也可以.来个完整的好不好啊.我要疯啦.
表:表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
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