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.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Delete Syntax help

Author  Topic 

tooba
Posting Yak Master

224 Posts

Posted - 2011-03-21 : 21:14:08
Hi,

Here is my sample data, In my source table i have more than 60k rows.

Date

2/10/2006
2/10/06
2/10/06
Thursday, 2/16/2006
Thursday, 2/16/2006
Thursday, 2/16/2006
Thursday, 2/16/2006
Thursday, 2/16/2006
Thursday, 2/16/2006
3/9/2006
3/9/2006
3/15/2006
7/7/06
7/7/06

How i can delete all Alpha values from my source data e.g I want to delete "Thursday"
Thanks in advance.

Vinnie881
Master Smack Fu Yak Hacker

1231 Posts

Posted - 2011-03-22 : 00:39:25
depends. 1 way is to write a function and go through each charecter which can take a little time to do, or if you are only deleting
"Monday","Tuesday",Wed,etc I would do this.


update a
set date = replace(replace(replace(replace(replace(replace(replace(replace(date,'Monday,',''),'Tuesday,',''),'Wednesday,',''),'Thursday,',''),'Friday,',''),'Saturday,',''),'Sunday,','')
from
mytable a

I haven't tested the code, so check for syntax.


Success is 10% Intelligence, 70% Determination, and 22% Stupidity.
\_/ _/ _/\_/ _/\_/ _/ _/- 881
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2011-03-22 : 04:35:53
or

select substring(col,patindex('%[0-9]%',col),len(col)) from table

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

tooba
Posting Yak Master

224 Posts

Posted - 2011-03-22 : 20:57:00
Thanks for your reply.
Go to Top of Page
   

- Advertisement -