Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Removing a character from the end of a text field.

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-07-23 : 00:32:52
Chris writes "I need to remove the ; character from the end of a text field in over 14,000 records in a SQL7 dB on NT4 sp5. I would like to reproduce the 'Trim' functionality found in Oracle where you can remove charaters from the end of a field in SQL7. I have tried using the following code but after about a minute I get an error. The SQL code and error are listed below. Please help!

SQL Code:

update badwordlist
set badwordlist.badword = Left(badwordlist.badword,(CHARINDEX(';',badwordlist.badword)-1))
where (badwordlist.badword Like '%;')

Error:

Server: Msg 2627, Level 14, State 1, Line 1
Violation of PRIMARY KEY constraint 'PK_BADWORDLIST'. Cannot insert duplicate key in object 'BADWORDLIST'.
The statement has been terminated."
   

- Advertisement -