Home > Blockchain >  How the Script activity output be pushed in form csv /structured format as a sink
How the Script activity output be pushed in form csv /structured format as a sink

Time:11-16

If i run the script activity ,it will give an output in json , how to push that data in csv /anyother format to blob/database ???

Consider i have 1 million rows outputed from Script activity(Single Query) ??

CodePudding user response:

We can take the json output of script actvity and copy it to SQL database. Below is the approach.

  • In Script actvity, Query is given in script settings. select * from sampletb

enter image description here

**Output of the script activity: **

enter image description here

  • Then Output of this activity is stored in a variable of string type. @string(activity('Script1').output.resultSets[0].rows)

enter image description here

  • In SQL database, target table named test_tgt is created.

  • Another script activity is taken and below script is written to copy to SQL database using below script.

declare @json nvarchar(4000)=N'@{variables('v1')}';
INSERT INTO test_tgt
SELECT * FROM OPENJSON(@json)
WITH (
Col varchar(60) ,
col1 varchar(50)
);

enter image description here

  • Related