|
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]
|