Reply to Re: replacing substring within string

Your name:

Reply:


Posted by Erland Sommarskog on 11/05/07 22:44

(mirandacascade@yahoo.com) writes:
> -- whenever @strValFromFrontEnd contains the substring 'abc',
> transform it such that
> -- it gets replaced by '123'; examples:
> -- @strValFromFrontEnd @strTransformedVal
> -- -------------------------------- ------------------------------
> -- four score abc and four score 123 and
> -- hello abc world abc yo hello 123 world 123 yo
>
> SET @strTransformedVal = ??
>
> Question: if the goal is to arrive at @strTransformedVal as described
> above, what is the best way to accomplish that...should one use the
> REPLACE function?

As long as the job is so simple that replace() does the job, why not
use it?

I would not be surprised, though, if you find that the affair is more
complex. Keep in mind that T-SQL is not the best tool for string
manipulation. If you are on SQL 2005, you have access to the CLR and
can use C# or VB.Net in SQL Server.


--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx

[Back to original 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

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