Link to home
Start Free TrialLog in
Avatar of Alex Jaya
Alex JayaFlag for United States of America

asked on

Export FOR JSON clause to an actual JSON File

I'm running a SQL query and using the FOR JSON PATH clause with child arrays.  The results show up fine when viewing the results to grid but I need a way to export it to an actual json file.  
I've read up on BCP but I can't seem to get it working mostly because I don't know how to use it.  I need to be able to use this as an automated scheduled job, preferably as a SQL job.  
Does anyone have any suggestions?

ASKER CERTIFIED SOLUTION
Avatar of ste5an
ste5an
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Alex Jaya

ASKER

Thank you, that worked, however, it exported all results into a single line json.  Is there a way to export it with each field in it's own line?
No, cause pretty print is for data representation not necessary, thus it is not done by FOR JSON.

When you want that, then you need to use a separate tool for that.