You are here: Re: how do i replace a substring in sqlserver ? « MsSQL Server « IT news, forums, messages
Re: how do i replace a substring in sqlserver ?

Posted by Jack Vamvas on 02/06/06 18:24

here is an example of SUBSTRING/REPLACE

CREATE TABLE #temp(stringRep VARCHAR(60))
INSERT INTO #temp(stringRep) VALUES('hazyCow')
INSERT INTO #temp(stringRep) VALUES('lazyCow')

DECLARE @startPos INT
SET @startPos = 2
UPDATE #temp SET stringRep = REPLACE(stringRep,SUBSTRING(stringRep, 2,
3),'zz')



SELECT * FROM #temp

DROP TABLE #temp

--
Jack Vamvas
__________________________________________________________________
Receive free SQL tips - register at www.ciquery.com/sqlserver.htm
SQL Server Performance Audit - check www.ciquery.com/sqlserver_audit.htm
New article by Jack Vamvas - SQL and Markov Chains -
www.ciquery.com/articles/art_04.asp

"David Greenberg" <davidgr@iba.org.il> wrote in message
news:43E77029.9010301@iba.org.il...
> Hi
> I have a character field, varchar(60), and I want to replace only a part
> of it, a set substring which is always in the same set positions.
> Does anyone have an Sql statement or algorithm/sp that could do that
> with one call or run ?
> Thanks
> David
>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация