Avatar of T Hoecherl
T Hoecherl
Flag for United States of America

asked on 

Concatenate results from mutlple sql queries

I have three SQL queries, each of which gives me a result.  What I want is for the results to be concatenated and either inserted in a table that can then be exported to a text file or directly to a text file.  For example, the first two queries and their results are:

Query1:
Select '<V1.0>,"' + substring(@Batch_Num, 7, 2 ) + substring(@Batch_Num, 10, 2) + 'C"'

Result:
<V1.0>,"2301C"

Query2:
Select '*,"' + substring(@Batch_Num, 2, 1) + substring(@Batch_Num, 4, 2) + substring(@Batch_Num, 7, 2 ) + substring(@Batch_Num, 10, 2) + 'c",,"PONUM",,,"' +
                + substring(@Batch_Num, 2, 1) + substring(@Batch_Num, 4, 2) + substring(@Batch_Num, 7, 2 ) + substring(@Batch_Num, 10, 2) + 'c.dat"'

Result:
*,"5112301c",,"PONUM",,,"5112301c.dat"

I want to run the queries together and get this result:
<V1.0>,"2301C"
*,"5112301c",,"PONUM",,,"5112301c.dat"

How can I accomplish this?

T
Microsoft SQL Server

Avatar of undefined
Last Comment
zephyr_hex (Megan)

8/22/2022 - Mon