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 |
|
rjhe22
Constraint Violating Yak Guru
283 Posts |
Posted - 2009-10-27 : 10:29:25
|
| i ahve a string and i want to leave the first 4 letters on will trim work and if so do i need to specify that i say want to trim the right side by 4 |
|
|
mfemenel
Professor Frink
1421 Posts |
Posted - 2009-10-27 : 10:36:38
|
| Trim is only for the leading and trailing spaces of a string such as ' my '. You'd want to use the left function such as left(mystring, 4).Mike"oh, that monkey is going to pay" |
 |
|
|
rjhe22
Constraint Violating Yak Guru
283 Posts |
Posted - 2009-10-27 : 10:39:11
|
| thanks for help |
 |
|
|
rjhe22
Constraint Violating Yak Guru
283 Posts |
Posted - 2009-10-27 : 10:40:23
|
| sorry one last thing. say i wanted to do it 4 from left side and 5 from the right side is that possible |
 |
|
|
mfemenel
Professor Frink
1421 Posts |
Posted - 2009-10-27 : 10:44:07
|
| left(mystring,4) + right(mystring,5)Mike"oh, that monkey is going to pay" |
 |
|
|
rjhe22
Constraint Violating Yak Guru
283 Posts |
Posted - 2009-10-27 : 11:27:32
|
| cant quite get it work the way i want.here is want i want to trimi just want the ango part of it |
 |
|
|
mfemenel
Professor Frink
1421 Posts |
Posted - 2009-10-27 : 11:39:15
|
| Ah. that's different. You want substring then. This will give you anylength of characters between the first and second -declare @mystring varchar(100)set @mystring='IE94-AN-9902-2000-5083-94'--select charindex('-',@mystring,charindex('-',@mystring)+1)select substring(@mystring, charindex('-',@mystring)+1, charindex('-',@mystring,charindex('-',@mystring)+1)-charindex('-',@mystring)-1 )Mike"oh, that monkey is going to pay" |
 |
|
|
rjhe22
Constraint Violating Yak Guru
283 Posts |
Posted - 2009-10-28 : 06:59:40
|
| thanks for help |
 |
|
|
|
|
|
|
|