Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
AdamWest
Constraint Violating Yak Guru
360 Posts |
Posted - 2014-06-27 : 08:49:43
|
Hi just want to know can you have unlimited UNION ALL's - can i add another group of SELECT to the end of this? how many times?SELECTcount(*)as Picking,0 AS LaserENGFROM CCDTA.OEORH48,CCDTA.TRNSTAT2,CCDTA.OETRA99 WHERE OHCOM# = TSCOM# AND OHORD# = TSORD# AND (otCOM# = OHCOM# AND OTORD#= OHORD# AND ottrnc = 'AQC') AND OHORDT IN('RTR','INT','SAM') AND TSSTAT IN('ECT','STP') AND OHREQD = replace(char(current date, iso), '-', '') AND OHHLDC = ' 'AND OHORD# in(SELECT a.TSORD# FROM ASTCCDTA.TRNSTAT2 a WHERE a.tsstat IN('AEP','BGE','EAS','REL','STP')) UNION ALL SELECT0,count(*) FROMCCDTA.OEORH48,CCDTA.TRNSTAT2,CCDTA.OETRA99 WHERE OHCOM# = TSCOM# AND OHORD# = TSORD# AND (otCOM# = OHCOM# AND OTORD#= OHORD# AND ottrnc = 'AQC') AND TSSTAT IN('EAS','REL','SCC') AND OHORDT IN('RTR','INT','SAM') AND OHREQD = replace(char(current date, iso), '-', '') AND OHHLDC = ' ' |
|
James K
Master Smack Fu Yak Hacker
3873 Posts |
Posted - 2014-06-27 : 08:52:32
|
You can have as many UNION ALL as you want. It is limited only by the maximum length of a query. |
 |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2014-06-27 : 09:21:24
|
I think you may hit the stack size limit with about 1300-1500 SELECTs. Microsoft SQL Server MVP, MCT, MCSE, MCSA, MCP, MCITP, MCTS, MCDBA |
 |
|
sardam98
Starting Member
10 Posts |
|
|
|
|
|
|