Registrations are now open. Join us today!
There is still a lot of work to do on the wiki yet! More information about editing can be found here.
Already have an account?

Microsoft KB Archive/170507

From BetaArchive Wiki
Knowledge Base

Article ID: 170507

Article Last Modified on 2/20/2004


  • Microsoft SQL Server 6.5 Service Pack 3
  • Microsoft SQL Server 7.0 Standard Edition

This article was previously published under Q170507

BUG #: 17087 (6.5)


The READTEXT statement will fail with "Msg 7134, Level 16, State 2" if both of the following conditions are true:

  • The text pointer provided is hard coded.


  • The READTEXT statement is the first statement of the batch.


To work around the problem, do either of the following:

  • Use a local variable to store the text pointer, instead of directly hard coding the text pointer value.


  • Make sure that the READTEXT statement is not the first statement in the batch. You can consider doing a "dummy" select, such as "select @@version".


Microsoft has confirmed this to be a problem in Microsoft SQL Server version 6.5 Service Pack 3. This problem was corrected in the latest Microsoft SQL Server 6.5 U.S. Service Pack. For information on obtaining the service pack, query on the following word in the Microsoft Knowledge Base (without the spaces):

   S E R V P A C K


The following code segment demonstrates the problem:

use pubs
create table test (Tvalue text)
insert into test values('This is a test')

select textptr(Tvalue) from test

-- To demonstrate the problem, the following hard coded text pointer
-- value should be based on the result of the previous select:

readtext test.Tvalue 0x510100000000000001000000aa100000 0

-- The following error message is displayed:
--    Msg 7134, Level 16, State 2
-- The following code segment works fine:

declare @txtptr  varbinary(16)
select @txtptr=textptr(Tvalue) from test
readtext test.Tvalue @txtptr 0 0

-- READTEXT only fails if it is the first statement of the batch.
-- The following code segment also works:

select * from titles where title_id = 'PS7777'
readtext test.Tvalue 0x510100000000000001000000aa100000 0

Additional query words: Transact-SQL T-SQL tsql transql transsql sp sp3

Keywords: kbbug kbfix kbusage KB170507