Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

BCP UNION QUERY

Status
Not open for further replies.

PETEHO

Programmer
Jan 17, 2002
45
0
0
GB
I am trying to run the following bcp union query. I have two queries on two tables that I am trying to join the output for. Individually they work but it doesn't like the UNION command. Any Ideas would be helpful

@bcp "select 'SL613' ,rtrim(posting_code),ltrim(rtrim(cast(cast(sum(journal_amount) as money) as char(20)))),rtrim(nlyear),'1' from SL613.scheme.nltranm WHERE nlyear = '07' and (trans_period < '02' or trans_period = 'O') group by posting_code,nlyear having sum(journal_amount) >= 0.01 or sum(journal_amount) <= -0.01 order by posting_code UNION select 'SL614' ,rtrim(posting_code),ltrim(rtrim(cast(cast(sum(journal_amount) as money) as char(20)))),rtrim(nlyear),'1' from SL614.scheme.nltranm WHERE nlyear = '07' and (trans_period < '02' or trans_period = 'O') group by posting_code,nlyear having sum(journal_amount) >= 0.01 or sum(journal_amount) <= -0.01 order by posting_code" queryout "S:\MANAGERS\Group Consolidation\2007 Consolidation\Batch Files\Jan\SLRL.txt" -S SVHOSAGE -T -t "," -r \n -c


Thanks

Pete
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top