首页 > 数据库技术 > 详细

sql替换字符

时间:2016-02-23 18:43:06      阅读:330      评论:0      收藏:0      [点我收藏+]
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

 

sql替换字符

原文:http://www.cnblogs.com/daixingqing/p/5210863.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!