我想动态替换表格列中的单词,因为我不知道需要替换多少个单词
SELECT * FROM `album` WHERE `prijs` BETWEEN 3 en AND 4
O / P
DECLARE @FormQuery NVARCHAR(max)='Case ',
@qry NVARCHAR(max)='';
SELECT @FormQuery = +COALESCE(@FormQuery
+ 'When ram.DynamicApplicableValueField Like ''%'
+ cmt.mastertype
+ '%'' Then replace (ram.DynamicApplicableValueField ,'''
+ cmt.mastertype + ''', rf.'
+ cmt.specialclausematchingcolumns + ') ', '')
FROM commonmastertypes cmt
JOIN (SELECT column_name
FROM information_schema.columns
WHERE table_name = 'ReeferDetails') spTable
ON cmt.specialclausematchingcolumns = spTable.column_name;
SELECT @FormQuery
预期结果
Case When ram.DynamicApplicableValueField Like '%@@Temp%' Then replace (ram.DynamicApplicableValueField ,'@@Temp', rf.Preset_Temperature) When ram.DynamicApplicableValueField Like '%@@Degree%' Then replace (ram.DynamicApplicableValueField ,'@@Degree', rf.Temp_UOM)