次のような構造のテーブルがあります
name properties
x thing1, thing2, thing3
y otherthing1, otherthing2, otherthing3
これを1対多の関係にマッピングしたいと思います
name properties
x thing1
x thing2
x thing3
私が持っているこの次のソリューションは機能しますが、SQL Server の Maxrecursion オプションに対して実行されます
;with tmp(brandName, drugList, genericName) as (
select brandName, LEFT(genericName, CHARINDEX(',',genericName+',')-1),
STUFF(genericName, 1, CHARINDEX(',',genericName+','), '')
from eeeee
where LEN(genericName) - LEN(replace(genericName,',','')) < 100
union all
select brandName, LEFT(genericName, CHARINDEX(',',genericName+',')-1),
STUFF(genericName, 1, CHARINDEX(',',genericName+','), '')
from tmp
where genericName > ''
)
select brandName, drugList
from tmp
order by brandName
このクエリを実行するのは where 句です。これは、リストに 100 を超える項目がある複数値列の行がいくつかあるためです。SQL Server の 100 の最大再帰制限をこっそりとオーバーライドする方法はありますか? それとも、100 を超える値を持つ列を 2 つに分割して再帰を実行するのが最善でしょうか?