| Author |
Topic |
|
vbjohn
Starting Member
32 Posts |
Posted - 2004-12-14 : 12:56:44
|
| I need a query that will remove the first 4 characters of a string andreplace them with 6 characters. |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2004-12-14 : 14:19:20
|
this smells like something the STUFF function will do. look that up in BOL.Go with the flow & have fun! Else fight the flow |
 |
|
|
vbjohn
Starting Member
32 Posts |
Posted - 2004-12-14 : 14:50:32
|
| Never heard of it. |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2004-12-14 : 15:16:08
|
| Did you look it up in SQL Server Books Online (BOL)?Tara |
 |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2004-12-14 : 15:45:21
|
| I love it ....Q: "can someone help me with ....?"A: "Try XYZ"Q: "XYZ? I never heard of it. no thanks. Is there anyone else that can help me?"- Jeff |
 |
|
|
vbjohn
Starting Member
32 Posts |
Posted - 2004-12-14 : 15:48:17
|
| I have been looking for it jsmith8858. Damn you are quick to reply with assumptions. |
 |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2004-12-14 : 15:52:46
|
| Do you have books on-line; see the FAQ here at sqlteam.it also might help if you are a little more descriptive, in both your question and in your response. If you have 4 characters, and you want to replace them with 6 characters ... that's somehow creating 2 characters .... perhaps it might be helpful for us to help you if you give us a little more info, such as what those 2 characters should be? (spaces? question marks? at the beginning of the string? at the end? replace the whole thing with a parictular word? )Does this make sense?- Jeff |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2004-12-14 : 15:53:13
|
| Open up SQL Server Books Online. Go to index tab. Type in Stuff. Hit enter, go to first topic in list.Tara |
 |
|
|
vbjohn
Starting Member
32 Posts |
Posted - 2004-12-14 : 15:56:26
|
| Yes it does -Jeff.......I do have books on-line. I havent used it before. I just never heard of that function. First 4 characters of a string to be replaced by 6 characters. Only the first four begining characters. |
 |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2004-12-14 : 16:01:30
|
| 4 characters to be replaced with WHAT ???? what 6 characters? ANY six characters?set @s = 'ANYSIX' + SUBSTRING(@s,5,1000)is that what you are looking for???Pretend you are not intimately familiar with your problem; step back, ignore what you know in your head and what have seen, and pretend you just saw the question you have posed to us out of the blue; can you possibly come up with an answer?Do you think an example and/or more information for us might be helpful??- Jeff |
 |
|
|
vbjohn
Starting Member
32 Posts |
Posted - 2004-12-14 : 16:07:32
|
| Ok.Tracking Number: 0021567Account Number: A001DeptID: 3ODeptID: 6We need to get rid of... 0021 and replace it with A00136It would come out to be:A00136567John- |
 |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2004-12-14 : 16:17:07
|
| SELECT AccountNumber+DeptID+ODeptID+SUBSTRING(TrackingNumber,4,LEN(TrackingNumber)-3)Brett8-) |
 |
|
|
vbjohn
Starting Member
32 Posts |
Posted - 2004-12-14 : 16:23:32
|
| Thanks. I will give this a try. |
 |
|
|
|