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 |
|
spawn1986
Starting Member
4 Posts |
Posted - 2010-03-10 : 13:40:52
|
Hi all, it's my first time here, but well, i need a solution for my problem, the problem is that i want to do a funtion to change a char in a string for examplei have this string 220440, and i need to replace 0 for nothing but only the 0 in the midleplease help with this problem Informatic |
|
|
spawn1986
Starting Member
4 Posts |
Posted - 2010-03-10 : 13:50:09
|
| please someone help me the database is in sqlserver please help meInformatic |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-03-10 : 13:52:14
|
| hint use CHARINDEX and SUBSTRING functions------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
spawn1986
Starting Member
4 Posts |
Posted - 2010-03-10 : 14:15:27
|
| ok do you know what is the structure of update with this method i dont know a lot sql programming please helpInformatic |
 |
|
|
CSears
Starting Member
39 Posts |
Posted - 2010-03-10 : 16:09:35
|
| LEN(@SourceString)will be helpful as well in verifying that you aren't taking off the last digit.http://msdn.microsoft.com/en-us/library/ms186323.aspxThis is the URL for the CHARINDEX Function, you can look up the other 2 there as well to find out how to use them properly. :) |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-03-10 : 16:29:36
|
What's about 220400 ?What are the rules to replace a 0 by nothing? No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
CSears
Starting Member
39 Posts |
Posted - 2010-03-10 : 16:42:44
|
| SET @VALUE = SUBSTRING(@VALUE, 1, 1) + REPLACE(SUBSTRING(@VALUE, 2, LEN(@VALUE)-2), '0', '') + SUBSTRING(@Value, LEN(@VALUE), 1)First CharSUBSTRING(@VALUE, 1, 1)Midsection with the replace statement being used to remove the valueREPLACE(SUBSTRING(@VALUE, 2, LEN(@VALUE)-2), '0', '')Last CharSUBSTRING(@Value, LEN(@VALUE), 1) |
 |
|
|
spawn1986
Starting Member
4 Posts |
Posted - 2010-03-11 : 21:55:31
|
| thanks for all i'll go to do that thanksInformatic |
 |
|
|
|
|
|
|
|