Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Command to replace a substring within a text column
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Versions des environnements
SQL Server:
SQL Server 2005
Application:
Web
Divers
Thread ID:
01371396
Message ID:
01371404
Vues:
17
This message has been marked as a message which has helped to the initial question of the thread.
>Hello all,
>
>I need to write a SQL UPDATE statement that will replace a substring within a column with a blank. The substring to replace can be any value so I cannot search on this, but I do know that the value to replace is between known values. The column is a varchar that has descriptive values in it as follows:
>
>'Buy xxxxxx vSymbol @.....Sell yyyyyy vSymbol @....'
>
>The 'Buy' and 'Sell' are constant. The vSymbol is variable but will be the same in the column and there is another column in the table that has this value so it can be referenced in the update statement. The xxxxxx and yyyyyy are variable and might not have the same value but these are to be replaced with a blank (along with the vSymbol). The '@' sign is also constant. I want the end result column to be as follows:
>
>'Buy @...... Sell @'
>
>TIA

Look at CHARINDEX(), REPLACE() and STUFF() functions in Help.

Try to experiment with different input strings until you get it right.
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform