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 |
|
a.ashabi
Posting Yak Master
117 Posts |
Posted - 2008-12-04 : 19:14:11
|
| Hi.I have a field with these values:PropelLemo3572877003615133Electro-Mi16292I want to delete the last 5 digits from it.to have :PropelLemo770036Electro-Miwhat should i do?thanks |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
Jai Krishna
Constraint Violating Yak Guru
333 Posts |
Posted - 2008-12-11 : 04:10:31
|
| select SUBSTRING(column,1,LEN(column)-5) FROM tableJai Krishna |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-12-11 : 08:01:54
|
quote: Originally posted by tkizer SELECT LEFT(Column1, DATALENGTH(Column1) - 5)FROM YourTableTara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/Subscribe to my blog
It depends on the datatype of the columndeclare @t table(data char(20))insert into @tselect 'PropelLemo35728' union allselect '77003615133' union allselect 'Electro-Mi16292'SELECT data,LEFT(data, DATALENGTH(data) - 5)FROM @tSELECT data,LEFT(data, LEN(data) - 5)FROM @tMadhivananFailing to plan is Planning to fail |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
|
|
|