|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Replace in Ntext Field
Hi All,
i am having difficulties to find a function replace some text into and NTEXT field of a SQLServer database. I need to remove a string that always come at the end of each records and is a fixed lenght, about 20 char. maybe can be done in 2 ways, a search and replace or a trm of the final part of the string. Anyone can suggest a piece of code to run? Thanks! |
|
#2
|
||||
|
||||
|
You can do this with a query that would look something like this. (Note: <name> indicates that you need to replace this with the appropriate name from your database.)
Update <tblName> SET <fieldName> = LEFT(<fieldName>,len(<fieldName>) - <20>) If some records will have the end text that needs to be removed and some won't you will to use a WHERE clause to filter them something like this: Update <tblName> SET <fieldName> = LEFT(<fieldName>,len(<fieldName>) - <20>) WHERE RIGHT(<fieldName>, <3>) = "foo" Enjoy! |
![]() |
| Viewing: Dev Articles Community Forums > Databases > Microsoft SQL Server > Replace in Ntext Field |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|