更新SQL Server 2008中的排列
我正在尝试编写TSQL来更新以下情况。
这是来自数据库的示例表。 表格中会有很多不同名字的行。
从Excelfile upload公司名称和国家。 以下是excel数据:
如果(公司的一部分=列A和国家=列B),我想得到以下结果。
我需要循环表吗?
问候
假设你有table1包含第一个样本数据,table2包含公司和contry。
你可以试试这个:
select t2.*, REPLACE(t2.company, t1.a, t1.c) as result from table2 t2 join table1 t1 on t2.company like '%'+t1.a and t2.contry = t1.b