title: SQL cannot export json file from 2 SQL queries
body: <p>I have this stored procedure where I export some data from a SQL Server table to json file.</p>
  <p>It works all fine when I only have one SQL query which makes sense because it exports only one json file.</p>
  <p>But what I want to do is create two json files from two SQL Server tables from a single procedure...</p>
  <p>Right now my stored procedure (working) looks like this:</p>
  <pre><code>ALTER PROCEDURE [dbo].[SP_PopulateJsonFiles]
  AS 
      DECLARE @sql varchar(1000)
      DECLARE @FileName varchar(500)
  
      SET @FileName = '\\C:\Projects\JsonFiles\Sqltable1.json'
      SET @sql = 'bcp &quot;' + 
      'select * from Sqltable1'+
          --if I add this line down it breaks the procedure and exports nothing :( 
          'select * from [Audit]'+
  
      ' FOR JSON PATH, INCLUDE_NULL_VALUES&quot; ' +
      'queryout  &quot;'+@FileName+ '&quot;' + 
      ' -c -S myMachine -d myDatabase-T'
  
      EXEC sys.XP_CMDSHELL @sql
  GO
  </code></pre>
  <p>So right now it only works if I only write <code>'select * from Sqltable1'+</code> but now if I put another select statement in it.</p>
  <p>I get that it runs into a conflict with the name because this way will try to create two documents with the same name, but how can I escape this and create two separate files with different names maybe?</p>
  <p>Thank you in advance.</p>