我正在使用SQL Server 2008 R2。我从excel导入了2个表格,我想将它们链接在一起。我是这样的:批量更新在主表记录上设置的子表记录
表从Excel导入
brand (nvarchar(20) name)
models (nvarchar(20) parent, nvarchar(50 name))
表后,我的赔罪
brand (int ident id, nvarchar(20) name, tinyint status)
models (int ident id, int parent_id,
nvarchar(20) parent, nvarchar(50) name, tinyint status)
正如你看到的,我想用ID使用PARENT_ID表品牌表款链接。
选择是好的,我已经做到了。
我需要的是创建批量更新,将品牌id放入模型parent_id中。
条件是:
set models.parent_id = brand.id where brand.name = model.parent
我希望这是显而易见的。基本上我想改变链接字段model.parent
到model.parent_id
。 brand.name可能会发生变化,如果发生这种情况,表格模型将无法链接到正确的父级。
而且我想大批量地完成所有品牌记录并更新模型中的所有相关记录。