BUG: Cursor Open 533 Error on UNION if MAX or MIN in SubqueryID: 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. We are researching this problem and will post new information
here in the Microsoft Knowledge Base as it becomes available.
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 : kbprg SSrvProg SSrvTran_SQL kbbug6.00
Version : 6.0
Platform : WINDOWS
Issue type :
Last Reviewed: March 24, 1999