BUG: Cursor Open 533 Error on UNION if MAX or MIN in Subquery |
Q147674
Errors can occur when you open a server cursor on a UNION query where the
unioned SELECTs contain correlated subqueries which contain MIN() or MAX().
Db-library clients see the following errors:
DB-Library error 10008: Possible network error: Bad token from SQL
Server: Datastream processing out of sync.
Msg 533, Level 20, State 4
Can't find a range table entry for range 4.
DB-Library Process Dead - Connection Broken
szSqlState = "S1000", *pfNativeError = 0,
szErrorMsg="[Microsoft][ODBC SQL Server Driver]
Unknown token received from SQL Server"
Microsoft has confirmed this to be a problem in the Microsoft SQL Server
version 6.00.
This problem no longer occurs in version 6.50.
Do not use a server cursor to process the command. Alternatively, perform
the two UNIONed SELECTs into temporary tables and then perform the union
between the temporary tables. For example, take:
select distinct t1.type
from titles t1
where t1.type in ( select max(t2.type)
from titles t2
where t1.pub_id != t2.pub_id )
union
select distinct t1.type
from titles t1
where t1.type in ( select max(t2.type)
from titles t2
where t1.pub_id != t2.pub_id )
and change it to:
select distinct t1.type into #temp1
from titles t1
where t1.type in ( select max(t2.type)
from titles t2
where t1.pub_id != t2.pub_id )
go
select distinct t1.type into #temp2
from titles t1
where t1.type in ( select max(t2.type)
from titles t2
where t1.pub_id != t2.pub_id )
go
select * from #temp1
union
select * from #temp2
Additional query words: sql6 cursor tsql
Keywords : kbprogramming
Issue type : kbbug
Technology : kbSQLServSearch kbAudDeveloper kbSQLServ600
|
Last Reviewed: March 28, 2000 © 2001 Microsoft Corporation. All rights reserved. Terms of Use. |