-5

I would like to know how to separate the string so that the result is like this

tax
company name branch #1-0
123456789123456
2022-05-14 01:51:09
38.75
5.05
10-1 / B
Y29tcGFueSBuYW1lIGJyYW5jaCAjMS0wCjEyMzQ1Njc4OTEyMzQ1NgoyMDIyLTA1LTE0IDAxOjUxOjA5CjM4Ljc1CjUuMDUKMTAtMSAvIEI=

I would also like to know how the string is saved in the database

{ "SellerName": "company name branch #1-0" , "SellerTaxId": "123456789123456" , "SellerTimeStamp": "2022-05-14 01:51:09" , "TotalInvoiceIncludingTax": "38.75" , "TotalTax": "5.05" ,  "InvoiceNo": "10-1 / B" , "QRCode": "Y29tcGFueSBuYW1lIGJyYW5jaCAjMS0wCjEyMzQ1Njc4OTEyMzQ1NgoyMDIyLTA1LTE0IDAxOjUxOjA5CjM4Ljc1CjUuMDUKMTAtMSAvIEI=" }

image for save to table

image for spilt from table

halfer
  • 19,824
  • 17
  • 99
  • 186
  • What RDBMS are you using? This is a json string and how they are treated depends entirely on the specific database. – Error_2646 Jul 15 '22 at 15:44
  • While asking a question, you need to provide a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example): (1) DDL and sample data population, i.e. CREATE table(s) plus INSERT T-SQL statements. (2) What you need to do, i.e. logic and your code attempt implementation of it in T-SQL. (3) Desired output, based on the sample data in the #1 above. (4) Your SQL Server version (SELECT @@version;). All within the question, no images. – Yitzhak Khabinsky Jul 15 '22 at 16:01
  • I'm beginner i don't know too much – Mohammed Abdelrahman Jul 15 '22 at 16:07
  • 2
    @MohammedAbdelrahman The docs should get you on the right track https://learn.microsoft.com/en-us/sql/relational-databases/json/json-data-sql-server?view=sql-server-ver16 – Error_2646 Jul 15 '22 at 16:41

1 Answers1

1

** I fix it by this query thanks **

SELECT  
      [ID],
      [TAX],
      JSON_VALUE([TAX],'$.SellerName')as SellerName,
      JSON_VALUE([TAX],'$.SellerTaxId')as SellerTaxId,
      JSON_VALUE([TAX],'$.SellerTimeStamp')as SellerTimeStamp,
      JSON_VALUE([TAX],'$.TotalInvoiceIncludingTax')as TotalInvoiceIncludingTax,
      JSON_VALUE([TAX],'$.TotalTax')as TotalTax,
      JSON_VALUE([TAX],'$.InvoiceNo')as InvoiceNo,
      JSON_VALUE([TAX],'$.QRCode')as QRCode
      
    FROM 
        [fcs_gurban].[dbo].[TaxJosn]
    WHERE
        ISJSON([TAX])>0
  • 1
    As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jul 18 '22 at 01:47