• mpradeep23 (2/10/2014)


    Hi

    i have table called t1

    with column name offers with data as

    "entitlementwrapper" : [ {

    "Type" : "Factory Warranty",

    "Date_Type" : "Ship date",

    "Status" : "Active",

    "Start_Date" : "2012-12-21",

    "End_Date" : "2014-01-19",

    "Days_Left" : "116",

    "Term" : "13",

    "Description" : "Wty: HP HW Replacement Support",

    "IsTrusted" : "Y",

    "Transaction_ID" : "4644780453"

    },

    i want to get data to store in other table

    1.type

    2.start_date

    3.end_date

    i need queery to load data into this table

    thanks,

    Pradeep

    So your table is storing the JSON in some form of character column. Got it.

    You cannot DIRECTLY do what you want. You cannot write a SELECT statement against JSON data in SQL Server. You need to first use some mechanism to PARSE your JSON into some type of tabular format (I recommend SQL CLR for that personally). You could write TSQL to do the parsing but TSQL is not very good at that (if you pursue it, look up SUBSTRING and CHARINDEX). You can also likely (not certain) do some XML stuff to work the parsing too. I foresee numerous complexities (and thus time involvement) in creating rigorous parsing code here, so I consider this beyond the realm of a forum post for assistance. Perhaps someone else will take up the charge here.

    Best of luck!

    Best,
    Kevin G. Boles
    SQL Server Consultant
    SQL MVP 2007-2012
    TheSQLGuru on googles mail service