如何使用rownumber? [英] How to use rownumber?

查看:61
本文介绍了如何使用rownumber?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将从这个字符串中获得一个@ json1



I will get one out put from this string @json1

{                
   "Status": "Success",                
   "Status Message": "Service Call Successful",                
   "Area":                
   [                
    
    {                
     "AreaCode":"A00009",                
     "AreaName":"BARSHI",                
     "FsCode":"TSM010",               
     "RegionCode":"R00001",                
     "RegionName":"MAHARASHTRA"                
   }, 
   {                
     "AreaCode":"A00008",                
     "AreaName":"BANGALORE",                
     "FsCode":"TSM040",               
     "RegionCode":"R00901",                
     "RegionName":"KARNATAKA"                
   },                              
    ]                
        }



现在我想要替换'}'之间的最后一个字符''' d']'符号任何解决方案都将不胜感激..



我尝试过:



i已经尝试了


now i want to replace last charecter ',' between '}' and ']' symbol any solution would be greatly appreciated..

What I have tried:

i have tried

set @json1=reverse(STUFF(REVERSE(@json1),charindex(',',@json1),1,''))





但没有用..

i希望像这样出来





but no use..
i want out put like this

{                
   "Status": "Success",                
   "Status Message": "Service Call Successful",                
   "Area":                
[                
    
    {                
     "AreaCode":"A00009",                
     "AreaName":"BARSHI",                
     "FsCode":"TSM010",               
     "RegionCode":"R00001",                
     "RegionName":"MAHARASHTRA"                
   }, 
   {                
     "AreaCode":"A00008",                
     "AreaName":"BANGALORE",                
     "FsCode":"TSM040",               
     "RegionCode":"R00901",                
     "RegionName":"KARNATAKA"                
   }                              
   ]                
}

推荐答案

这是解决方案(相应):



SET @ json1 = REVERSE(STUFF(REVERSE(@ json1),CHARINDEX(',',REVERSE(@ json1)),1,'')



你几乎没事。
Here's the solution (accordingly):

SET @json1 = REVERSE(STUFF(REVERSE(@json1),CHARINDEX(',',REVERSE(@json1)),1,''))

You almost had it right.


这篇关于如何使用rownumber?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆