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 2008 Forums
 Transact-SQL (2008)
 update query replace

Author  Topic 

cplusplus
Aged Yak Warrior

567 Posts

Posted - 2011-10-06 : 12:19:06
i want to update the english text column, just want to remove the last two chars which is space and 'v'

" v" before updating if the last two charecters are a space and v then remove just the last two letters only. keep the rest same.

i have almost 2200 rows in this table.

declare @Sample table (ID int, englishtext)
insert @Sample
select 1, 'MyText1 v' union all
select 2, 'mytext2 v' union all
select 3, 'mytext3' union all
select 4, 'mytext4 v' union all
select 5, 'mytext5' union all
select 6, mytext6' union all
select 7, 'mytext7 v'

once i do the update it should be:

Mytext1
MyText2
Mytext3
Mytext4
Mytext5
Mytext6
Mytext7


Update @Sample set englishtext=


Thank you very much for the helpful info

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-10-06 : 12:23:55
[code]Update @Sample set englishtext=left(englishtext,len(englishtext)-2)
where patindex('% v',englishtext) >0
[/code]

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -