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 |
|
KenA
Starting Member
28 Posts |
Posted - 2005-10-18 : 13:52:00
|
| Hi. When using the UNION command in Sql Server, I´ve notice that there´s some limits like: SELECT '99232018' AS serie UNION SELECT '99232003' AS serie UNION SELECT '99231032' AS serie UNION.....--around 1000 lines....I get the following error msg: Server: Msg 8621, Level 17, State 1, Line 2Internal Query Processor Error: The query processor ran out of stack space during query optimization.Is there a limitation in the qty of UNIONs I can run or is it a limitation o server memory?Or, is there another way (more optimized) that I could make a insert statement to retrieve multiples lines?Regrads, Ken»»» Ken.A |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2005-10-18 : 14:02:21
|
| INSERT INTO Table1VALUES('99232018')INSERT INTO Table1VALUES('99231032')...Tara |
 |
|
|
sachinsamuel
Constraint Violating Yak Guru
383 Posts |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2005-10-18 : 14:40:14
|
quote: Originally posted by KenA Hi. When using the UNION command in Sql Server, I´ve notice that there´s some limits like: SELECT '99232018' AS serie UNION SELECT '99232003' AS serie UNION SELECT '99231032' AS serie UNION.....--around 1000 lines....I get the following error msg: Server: Msg 8621, Level 17, State 1, Line 2Internal Query Processor Error: The query processor ran out of stack space during query optimization.Is there a limitation in the qty of UNIONs I can run or is it a limitation o server memory?Or, is there another way (more optimized) that I could make a insert statement to retrieve multiples lines?Regrads, Ken»»» Ken.A
Why are you trying to do this? You might want to consider storing these values in a table, since databases tend to be good at that sort of thing! And by the way -- use UNION ALL instead of union unless you are depending on the fact that UNION removes duplicate values. If you don't need this behavoir, a UNION ALL is much more efficient. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-10-19 : 02:00:34
|
| Also Union will unnecessarily sort the records whereas Union All doesnt do it unless you explicitly use Order ByMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|
|
|