sql替换字符
declare @name varchar(100)='"acct_name"',@card varchar(100)='"id_no"' SELECT TOP 100 stuff( STUFF(Json, CHARINDEX(@name, Json) + LEN(@name) + 2, CHARINDEX(',',Json,CHARINDEX(@name, Json) + LEN(@name)) - CHARINDEX(@name, Json) - LEN(@name) - 3, replicate('*',CHARINDEX(',',Json,CHARINDEX(@name, Json) + LEN(@name)) - CHARINDEX(@name, Json) - LEN(@name) - 3) ), CHARINDEX(@card, Json) + LEN(@card) + 6, CHARINDEX(',',Json,CHARINDEX(@card, Json) + LEN(@name)) - CHARINDEX(@card, Json) - LEN(@card) - 11, replicate('*',CHARINDEX(',',Json,CHARINDEX(@card, Json) + LEN(@name)) - CHARINDEX(@card, Json) - LEN(@card) - 11) ), CHARINDEX(@name, Json) + LEN(@name) + 2, CHARINDEX(',',Json,CHARINDEX(@name, Json) + LEN(@name)) - CHARINDEX(@name, Json) - LEN(@name) - 3, CHARINDEX(@card, Json) + LEN(@card) + 6, CHARINDEX(',',Json,CHARINDEX(@card, Json) + LEN(@name)) - CHARINDEX(@card, Json) - LEN(@card) - 11, --SUBSTRING(Json, 0, CHARINDEX(@name, Json) + LEN(@name) + 2) + --REPLICATE('*', CHARINDEX(',',Json,CHARINDEX(@name, Json) + LEN(@name)) - CHARINDEX(@name, Json) - LEN(@name) - 3) --stuff Json FROM dbo.Z_UserBankInfo WHERE json IS NOT null