JSON arrays using FOR JSON PATH SQLHow can I prevent SQL injection in PHP?Add a column with a default value to an existing table in SQL ServerHow do I format a Microsoft JSON date?Can comments be used in JSON?How can I pretty-print JSON in a shell script?Inserting multiple rows in a single SQL query?What is the correct JSON content type?How do I UPDATE from a SELECT in SQL Server?Why does Google prepend while(1); to their JSON responses?What are the options for storing hierarchical data in a relational database?

Why am I getting an electric shock from the water in my hot tub?

Which are more efficient in putting out wildfires: planes or helicopters?

What is this fluorinated organic substance?

Existence of infinite set of positive integers s.t sum of reciprocals is rational and set of primes dividing an element is infinite

Trace in the category of propositional statements

GFCI versus circuit breaker

Was Wolfgang Unziker the last Amateur GM?

Merging two data frames into a new one with unique items marked with 1 or 0

Why would Dementors torture a Death Eater if they are loyal to Voldemort?

Are the plates of a battery really charged?

Are all notation equal by derivatives?

Square wave to sawtooth wave using two BJT

What was the ASCII end of medium (EM) character intended to be used for?

Which high-degree derivatives play an essential role?

Is it theoretically possible to hack printer using scanner tray?

How to track mail undetectably?

What does this Pokemon Trainer mean by saying the player is "SHELLOS"?

Is this house-rule removing the increased effect of cantrips at higher character levels balanced?

Variable declaration inside main loop

Can I hire several veteran soldiers to accompany me?

Emphasize numbers in tables

Tricky riddle from sister

What could a Medieval society do with excess animal blood?

How soon after takeoff can you recline your airplane seat?



JSON arrays using FOR JSON PATH SQL


How can I prevent SQL injection in PHP?Add a column with a default value to an existing table in SQL ServerHow do I format a Microsoft JSON date?Can comments be used in JSON?How can I pretty-print JSON in a shell script?Inserting multiple rows in a single SQL query?What is the correct JSON content type?How do I UPDATE from a SELECT in SQL Server?Why does Google prepend while(1); to their JSON responses?What are the options for storing hierarchical data in a relational database?













0















First time using FOR JSON PATH in MSSQL to generate a JSON output as below, HELP! I need to create a JSON output like that from a SQL View, I am having trouble writing the Query using FOR PATH specially for the UNCCID and ViewModels array




"UNCCID": 4,
"viewModels": [

"year": 2019,
"departments":
"IT":
"id": 1,
"name": "Computer Science",
"Teachers": [

"name": "ABC",
"teacher_id": 1,
,

"name": "ZXQ",
"teacher_id": 2,

]



]


My Table looks like this



Table View










share|improve this question
























  • What is your view structure?

    – Zhorov
    Mar 25 at 17:26











  • @Zhorov I have added my table on the Q please take a look mostly its only have values which I have to join with another table

    – Rudy
    Mar 25 at 18:07











  • Please post the structure of all tables involved and how they are linked together.

    – Andrea
    Mar 27 at 10:53















0















First time using FOR JSON PATH in MSSQL to generate a JSON output as below, HELP! I need to create a JSON output like that from a SQL View, I am having trouble writing the Query using FOR PATH specially for the UNCCID and ViewModels array




"UNCCID": 4,
"viewModels": [

"year": 2019,
"departments":
"IT":
"id": 1,
"name": "Computer Science",
"Teachers": [

"name": "ABC",
"teacher_id": 1,
,

"name": "ZXQ",
"teacher_id": 2,

]



]


My Table looks like this



Table View










share|improve this question
























  • What is your view structure?

    – Zhorov
    Mar 25 at 17:26











  • @Zhorov I have added my table on the Q please take a look mostly its only have values which I have to join with another table

    – Rudy
    Mar 25 at 18:07











  • Please post the structure of all tables involved and how they are linked together.

    – Andrea
    Mar 27 at 10:53













0












0








0


1






First time using FOR JSON PATH in MSSQL to generate a JSON output as below, HELP! I need to create a JSON output like that from a SQL View, I am having trouble writing the Query using FOR PATH specially for the UNCCID and ViewModels array




"UNCCID": 4,
"viewModels": [

"year": 2019,
"departments":
"IT":
"id": 1,
"name": "Computer Science",
"Teachers": [

"name": "ABC",
"teacher_id": 1,
,

"name": "ZXQ",
"teacher_id": 2,

]



]


My Table looks like this



Table View










share|improve this question
















First time using FOR JSON PATH in MSSQL to generate a JSON output as below, HELP! I need to create a JSON output like that from a SQL View, I am having trouble writing the Query using FOR PATH specially for the UNCCID and ViewModels array




"UNCCID": 4,
"viewModels": [

"year": 2019,
"departments":
"IT":
"id": 1,
"name": "Computer Science",
"Teachers": [

"name": "ABC",
"teacher_id": 1,
,

"name": "ZXQ",
"teacher_id": 2,

]



]


My Table looks like this



Table View







sql json sql-server






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 25 at 18:06







Rudy

















asked Mar 25 at 17:23









RudyRudy

1441 gold badge2 silver badges12 bronze badges




1441 gold badge2 silver badges12 bronze badges












  • What is your view structure?

    – Zhorov
    Mar 25 at 17:26











  • @Zhorov I have added my table on the Q please take a look mostly its only have values which I have to join with another table

    – Rudy
    Mar 25 at 18:07











  • Please post the structure of all tables involved and how they are linked together.

    – Andrea
    Mar 27 at 10:53

















  • What is your view structure?

    – Zhorov
    Mar 25 at 17:26











  • @Zhorov I have added my table on the Q please take a look mostly its only have values which I have to join with another table

    – Rudy
    Mar 25 at 18:07











  • Please post the structure of all tables involved and how they are linked together.

    – Andrea
    Mar 27 at 10:53
















What is your view structure?

– Zhorov
Mar 25 at 17:26





What is your view structure?

– Zhorov
Mar 25 at 17:26













@Zhorov I have added my table on the Q please take a look mostly its only have values which I have to join with another table

– Rudy
Mar 25 at 18:07





@Zhorov I have added my table on the Q please take a look mostly its only have values which I have to join with another table

– Rudy
Mar 25 at 18:07













Please post the structure of all tables involved and how they are linked together.

– Andrea
Mar 27 at 10:53





Please post the structure of all tables involved and how they are linked together.

– Andrea
Mar 27 at 10:53










0






active

oldest

votes










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55343345%2fjson-arrays-using-for-json-path-sql%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes




Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.







Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55343345%2fjson-arrays-using-for-json-path-sql%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript