Replace string within a blob file

  • I have a blob file in SQL Server 2000 where I need to find all instances of  ':' and replace with '--'.  I tried the following SQL statement:

    select replace(GDTXVC, ':', '-') from proddta.f00165 where gdtxky= '2514|SO|00001|1.000'

    But,  received this error message: Argument data type text is invalid for argument 1 of replace function.

    Is there a special statement which will work on this field for a replace command? 

    Thanks!

    Heather

     

  • Hi there,

    I'm not sure I understand exactly what your table looks like.  Is the blob implemented as a "text" datatype?  If so then you might look in BOL for UPDATETEXT and TEXTPTR.  Another possibility is to pull the data out to a varchar(8000) work area with READTEXT, modify the data using replace, and write it back to the text column with WRITETEXT.  Basically write your own clone for the replace function.  I am not aware of a direct equivalent for text columns, which is not to say that there isn't one.

    Hope this helps

    Wayne

  •   Thanks for pointing me in the right direction.  I found a script that I was able to edit which utilized the UPDATETEXT, TEXTPTR, and Cursor functions to locate the position where the character to be replaced was stored. 

  • Please send to script to help others who may wish to utilize it

    Brett

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply