Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 5th, 2007, 12:04 PM
Banned
 
Join Date: Jul 2005
Posts: 317
Thanks: 0
Thanked 0 Times in 0 Posts
Default UPDATETEXT Problem: replace one value with another

I need to replace a few strange characters that are located in a table field that has a text datatype. My first try is to replace an arrow character (code: #9658;) with a dash.

I found a MS article on the UPDATETEXT method at http://msdn2.microsoft.com/en-us/library/aa260658(sql.80).aspx

...which provides the following example:
[code]DECLARE @ptrval binary(16)
SELECT @ptrval = TEXTPTR(pr_info)
   FROM pub_info pr, publishers p
      WHERE p.pub_id = pr.pub_id
      AND p.pub_name = 'New Moon Books'
UPDATETEXT pub_info.pr_info @ptrval 88 1 'b'
GO

I customized it to create the following stored procedure:
Code:
CREATE PROCEDURE [dbo].[spRemoveArrow]
@arrow binary(16) AS

SELECT @arrow = TEXTPTR(details)
FROM         tblTableName
WHERE     (details LIKE '%#9658;%')

UPDATETEXT tblTableName.details @arrow NULL 7 '-'
GO
...but I receive the following error message:
Server: Msg 257, Level 16, State 2, Procedure spRemoveArrow, Line 0
Implicit conversion from data type varchar to binary is not allowed. Use the CONVERT function to run this query.

I've messed around with it a bit to see if I could fix the problem, but I can't figure out how to do this. If anyone could let me know what I'm doing wrong, it would be greatly appreciated. Thanks.

KWilliams





Similar Threads
Thread Thread Starter Forum Replies Last Post
Replace In c# jayanth_nadig SQL Language 2 July 3rd, 2006 03:25 AM
replace ' and " with \' and \" Brian Campbell XSLT 4 May 24th, 2006 10:49 AM
Problem with redirect/replace gorros Javascript 4 March 11th, 2006 07:37 AM
replace "." with "/" thelos Excel VBA 1 September 14th, 2005 10:47 AM
Replace problem neo_jakey Classic ASP Basics 2 January 8th, 2004 10:00 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.