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 |
|
jarredcody
Starting Member
5 Posts |
Posted - 2010-03-24 : 21:56:22
|
| Will this work if the field name is PHONE_NUMBER in the table PHONE, database RWD?Not sure what to subsitute and where...?**************************************************************UPDATE [RWD].[dbo].[PHONE]Declare @s varchar(100),@result varchar(100)set @s='as4khd0939sdf78'set @result=''select@result=@result+case when number like '[0-9]' then number else '' end from (select substring(@s,number,1) as number from (select number from master..spt_values where type='p' and number between 1 and len(@s)) as t) as tselect @result as only_numbersselect case when left(@result,1)='1' then stuff(@result,1,1,'') else @result end as number |
|
|
vaibhavktiwari83
Aged Yak Warrior
843 Posts |
Posted - 2010-03-25 : 02:07:47
|
| what are you trying to do ?Vaibhav T |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-03-25 : 11:42:42
|
quote: Originally posted by jarredcody Will this work if the field name is PHONE_NUMBER in the table PHONE, database RWD?Not sure what to subsitute and where...?**************************************************************UPDATE [RWD].[dbo].[PHONE]Declare @s varchar(100),@result varchar(100)set @s='as4khd0939sdf78'set @result=''select@result=@result+case when number like '[0-9]' then number else '' end from (select substring(@s,number,1) as number from (select number from master..spt_values where type='p' and number between 1 and len(@s)) as t) as tselect @result as only_numbersselect case when left(@result,1)='1' then stuff(@result,1,1,'') else @result end as number
you need make code snippet into a function and then use it in update ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|
|
|