Skip to content
Advertisement

Add a column which stores JSON data

I have created table like:

CREATE TABLE demo
(
    name varchar(50), 
    adress nvarchar
);

But I’m not getting how to insert data into adress column which stores data of JSON object like:

INSERT INTO demo (name, adress) 
VALUES ('vamsi', N'{"city":"avhfb","pin":46374});

Like this: The values I get in this adress column is dynamic count so that’s why I need to store it in JSON format.

Advertisement

Answer

Don’t overthink it. JSON is still a string, so nvarchar will be fine, but add a length to they datatype (probably nvarchar(max) for a JSON object).

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement