我有一个数据库,它有以下字段: Product、Asset、Serial、Serial、Serial、等等。这些字段是从excel工作表中导入的。我现在需要从excel表中导入一个额外的字段到DB中,我一开始就花了几个小时来格式化表单,我不想再这样做了。
还有一个名为productnumber的附加字段。
假设我只是将所有excel数据杂乱无章地导入到sql db的另一个表中。
我可以说什么函数/查询/什么?
foreach( item in table1) {
if(item.serial = table2.serial) {
item.productnumber = table2.productnumber
}
}我在脑海中看到了可数据,但我不确定在继续前进之前,我将如何让每一行检查一整张表?
谢谢各位
编辑:好的,我现在有两个表
table1和表2
表1,ID,\n,名称,\##*#.表2系列编号:_
现在我需要将所有数据从table2.tag复制到table1.tag并在assetNo上匹配
谢谢
发布于 2013-11-05 16:39:05
最好的方法是直接将excel表导入到sql server数据库中,然后在原始表中添加列并执行更新操作。
假设您的原始表是table1,而serial是主键。将数据从excel导入到一个新的表中,比如table2。修改table1并添加必要的字段(productnumber)。
执行以下更新查询
update table2 set table2.productnumber =table1.productnumber
from table2 inner join table1 on table2.serial = table1.serialhttps://stackoverflow.com/questions/19793688
复制相似问题