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

T-SQL: how manage TEXT field????

Status
Not open for further replies.

daniela

Programmer
Mar 29, 2000
3
IT
I work on SQL SERVER 7.0 <br>with&nbsp;&nbsp;T-SQL I have to read a TEXT field <br>and write it into a new record, but..... <br>What happen is: <br><br>DECLARE @ptr1 varbinary(16), @ptr2 varbinary(16) <br><br>SELECT @ptr1 = TEXTPTR(DESCRIPTION) <br>FROM tableA <br>WHERE ID = 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br><br>READTEXT tableA.DESCRIPTION @ptr1 0 6&nbsp;&nbsp;&nbsp;--OFFSET <br><br>SELECT @ptr1 = TEXTPTR(DESCRIPTION) <br>FROM tableA <br>WHERE ID = 1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br><br>WRITETEXT tableA.DESCRIPTION @ptr2 @ptr1 <br><br>/*********************************** <br>results tableA: <br>ID&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DESCRIPTION (text) <br>---------------------------- <br>&nbsp;&nbsp;0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;minnie <br>&nbsp;&nbsp;1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ÿÿÿYYY <br>**********************************/ <br>The result is really not what I expected!!!!! <br>What I wrong? <br>Or what i can do?? <br><br><b>Many Thanks.</b> <br>Dan <br>
 
Why don't you use an update?<br><br>UPDATE TABLEA<br>SET DESCRIPTION = (SELECT DESCRIPTION <br>FROM TABLEA WHERE ID=0)<br>WHERE ID=1<br>GO<br><br>This will update ID1 description to ID0 description. Is this what you want?
 
Thank for your reply .............<br><br>but it is not possible an Update if you have to manage a field which data type is TEXT....<br><b>AT LEAST with&nbsp;&nbsp;MS SQL SERVER (7.0) IT' S NOT POSSIBLE<br>I'M AFRAID </b><br><br>I've already tried what suggested me but the response was:<br>ERROR:<br>&lt;The text, ntext, and image data types are invalid in this subquery or aggregate expression. &gt;<br><br>Right now, I use a <br>&nbsp;&nbsp;@tmp varchar (8000) <br>which read in blocks the old field<br>and then write in blocks&nbsp;&nbsp;the&nbsp;&nbsp;new TEXT field!!!!<br>Practically,<br>I 've got to write a little store procedure like GetChunk to manage a simple TEXT field.........<br>THAT 'S INCREDIBLE.....................<br><br>
 
could you use the UPDATETEXT statement as you can specify a source column from another table?
 
<b>Both UPDATETEXT AND WRITTEXT make only an update on the field you give them by a pointer </b>.....<br><br>I have to read from a field A1<br>and then write it to the field A2......<br><br>and i remeber that field A has datatype TEXT<br>My problem is that you can't do:<br><br>SELECT A FROM TABLEX.....<br><br>You can't retrive a TEXT field in such a way. <br>You MUST use the statement READTEXT, but it's like PRINT<br>you can't manage the output of these statement!!!!!<br><br>So...the question is:<br><b>how could you specify the source field to the statement UPDATETEXT or WRITETEXT ???&nbsp;&nbsp;</b><br><br><br>Have you got any other suggestion?<br>BYE Dan<br><br><br><br><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top