Advertisement
Guest User

Untitled

a guest
Apr 28th, 2015
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. OrderId Name JSON
  2.  
  3. {
  4. "Property1" :"",
  5. "Property2" :"",
  6. "metadata-department": "A",
  7. "metadata-group": "B"
  8. }
  9.  
  10. declare @string varchar(1000) =
  11. '{
  12. "Property1" :"",
  13. "Property2" :"",
  14. "metadata-department": "A",
  15. "metadata-group": "B"
  16. }'
  17.  
  18.  
  19. select SUBSTRING(@string, 0, CHARINDEX('"metadata-department"',@string)) + SUBSTRING(@string, CHARINDEX('"metadata-group"', @string), len(@string))
  20.  
  21. {
  22. "Property1" :"",
  23. "Property2" :"",
  24. "metadata-group": "B"
  25. }
  26.  
  27. UPDATE TableX
  28. SET JSON =
  29. SUBSTRING(JSON, 0, CHARINDEX('"metadata-department"',JSON)) + SUBSTRING(JSON, CHARINDEX('"metadata-group"', JSON), len(JSON))
  30.  
  31. DECLARE @Text NVARCHAR(MAX) = '{
  32. "Property1" :"",
  33. "Property2" :"",
  34. "metadata-department": "A",
  35. "metadata-group": "B"
  36. }';
  37.  
  38. PRINT dbo.RegExReplace(@Text, '"metadata-department": "[A-Za-z0-z]",rns+', '');
  39.  
  40. {
  41. "Property1" :"",
  42. "Property2" :"",
  43. "metadata-group": "B"
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement