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)
 Locate data in a field, and replace

Author  Topic 

HoodRat
Starting Member

1 Post

Posted - 2006-06-08 : 13:15:51
I am trying to figure out how to locate a specific set of data, in a field, delimited with commas. ex "987654,654987,123456"
I want to write a query that will locate the entry that has 654987, and update that cell with "987654,123456" thus deleting the middle entry.

Any ideas?

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-06-08 : 13:46:54
[code]
UPDATE Table1
SET Field1 = LEFT(REPLACE(Field1 + ',', '654987' + ',', ','), LEN(Field1))
WHERE CHARINDEX('654987' + ',', Field1 + ',') > 0
[/code]
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-06-09 : 11:07:20
Do you store csv in a column?
Read about Normalisation
http://www.datamodel.org/NormalizationRules.html

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -