Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 SQL Query Needed

Author  Topic 

kamalkishore_in
Yak Posting Veteran

76 Posts

Posted - 2004-07-23 : 04:08:36
Hi friends,

Here is my Query :

I have a field Named DESCRIPTION Varchar(200).
I Need make a SEARCH and REPLACE FORM in which the user will INPUT a word in SEARCH BOX and Another Word in REPLACE BOX.

I have to search the the WORD Which There in SEARCH BOX in DESCRIPTION field and replace that perticular word with the another WORD which the use has entered in in REPLACE BOX.

Thankx in Advance
Waiting for your Reple...

ditch
Master Smack Fu Yak Hacker

1466 Posts

Posted - 2004-07-23 : 04:36:52
Use Replace.

something like this:

CREATE Table #A(Field1 VARCHAR(200))

INSERT INTO #A VALUES('Hello World');
INSERT INTO #A VALUES('Hi World');


SELECT * From #A


DECLARE @Old as VARCHAR(200)
DECLARE @New as VARCHAR(200)

SET @Old = 'Hello'
SET @New = 'Good Bye'

UPDATE #A
SET Field1 = Replace(Field1, @Old, @New)

SELECT * FROM #A

Duane.
Go to Top of Page
   

- Advertisement -