2

i want to take value (In SQL Server) in json object without JSON_VALUE

The json value :

{{
  "Url": "****",
  "Token": "",
  "Data": {
    "role_id": 1001,
    "data": {
      "stringvalue": [
        {
          "minage": "21"
        },
        {
          "maxage": "55"
        },
        {
          "primary_identity_file": "data:image/jpeg;base64,/9j/4AAQSkZJRgABAgAAAQABAAD/7QCcUGhvdG9zaG9wIDMuMAA4QklNBAQAAAAAAIAcAmcAFHpFZEQyY1ZzbGVyRzNrcF8yTjhHHAIoAGJGQk1EMDEwMDBhYzAwMzAwMDAwMjMxMDAwMDQxNzQwMDAwYjQ3YjAwMDBhMTgyMDAwMDliY2EwMDAwMjkyMDAxMDBmODJhMDEwMGFiMzQwMTAwMDgzZTAxMDBjZGM0MDEwMP/iAhxJQ0NfUFJPRklMRQABAQAAAgxsY21zAhAAAG1udHJSR0IgWFlaIA"
        }
      ]
    }
  }
}}

what i trying to do is to take "primary_identity_file" value

the result should be :

data:image/jpeg;base64,/9j/4AAQSkZJRgABAgAAAQABAAD/7QCcUGhvdG9zaG9wIDMuMAA4QklNBAQAAAAAAIAcAmcAFHpFZEQyY1ZzbGVyRzNrcF8yTjhHHAIoAGJGQk1EMDEwMDBhYzAwMzAwMDAwMjMxMDAwMDQxNzQwMDAwYjQ3YjAwMDBhMTgyMDAwMDliY2EwMDAwMjkyMDAxMDBmODJhMDEwMGFiMzQwMTAwMDgzZTAxMDBjZGM0MDEwMP/iAhxJQ0NfUFJPRklMRQABAQAAAgxsY21zAhAAAG1udHJSR0IgWFlaIA

** NOTE primary_identity_file value is more than 10K character

1 Answer 1

2

I'd try something like that:

select substring(vlv3, 1, charindex('"', vlv3)-1) as vlv4
from (
    select substring(vlv2, charindex('"', vlv2)+1, len(vlv2)) as vlv3
    from (
        select substring(vlv, charindex('"primary_identity_file"', vlv)+23, len(vlv)) as vlv2
        from test
    ) as test2
) as test3

You can rewrite in more readable way as stored procedure

Sample fiddle http://sqlfiddle.com/#!18/a122b/7

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.