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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Stack overflow during compile time 1

Status
Not open for further replies.

riley3

Programmer
Apr 29, 2004
79
US
Hello,
I'm having a problem with a SQL 2K query. I keep getting an error message when using the Query Analyzer, "The server encountered a stack overflow during compile time." I have a table that has 800,000 + inventory records and I need to clean out some of them. However, I don't want to drop any records that are associated with a sales order because the inventory record is where the item description comes from. That's why even though some are over five years old and the qty avail is zero the description is still needed. This is my query.

select *
from parttable
where parttable.itemdate < 'Jan 1 2006'
and parttable.qtyavail < 1
and (parttable.itemno <> '7363317'
and parttable.itemno <> '7363703'
and parttable.itemno <> '7363710')

Only three itemno records related to sales orders are listed above, there are 6000+ of these records. When comparing the itemno's, if I use an "or" instead of "and" the query runs but the records do not kick out as needed. But when "and" is used the error message occurs. Once the query works I will change the select to a delete to get rid of the unwanted records. Can someone tell me what I'm doing wrong? Thanks Riley
 
select *
from parttable
where parttable.itemdate < 'Jan 1 2006'
and parttable.qtyavail < 1
[!]and parttable.itemno Not In ('7363317', '7363703', '7363710',etc...)[/!]

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Thanks George for the help. Your code works just fine. I had learned one way to set up a query but never thought to code it like your example. Thanks again, Riley
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top