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.
| Author |
Topic |
|
AdamWest
Constraint Violating Yak Guru
360 Posts |
Posted - 2011-02-22 : 16:24:57
|
| HI I Have many entries that have this 'HK' as a kind of prefix.while i have nothing against HK, the sales person would like this HK removed.the name of this column is categorynameHK-Dietary HK-Jan |
|
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
Posted - 2011-02-22 : 16:42:14
|
| http://msdn.microsoft.com/en-us/library/ms181984.aspx |
 |
|
|
MIK_2008
Master Smack Fu Yak Hacker
1054 Posts |
Posted - 2011-02-23 : 00:10:44
|
@lamprey @adam, right, replace |
 |
|
|
mmarovic
Aged Yak Warrior
518 Posts |
Posted - 2011-02-23 : 03:31:37
|
| substring, patindex?MirkoMy blog: http://mirko-marovic-eng.blogspot.com/ |
 |
|
|
mmarovic
Aged Yak Warrior
518 Posts |
Posted - 2011-02-23 : 04:56:43
|
Actually, substring is enough.case when categoryname like 'HK-%' then substring(...) else categoryNameend MirkoMy blog: http://mirko-marovic-eng.blogspot.com/ |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2011-02-23 : 05:38:16
|
-- making testdatadeclare @test table (ttt varchar(255))insert @testselect 'HK-123' union allselect 'HP-456' union allselect 'HK4588'-- solutionselect stuff(ttt,1,3,'') as result from @test where ttt like 'HK-%' No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
|
|
|