views:

45

answers:

1

I have a sql DB table columns which carries data in "0000-00-0000" format. For ex: "8753-11-2010"

Now i need to change this value from "8753-11-2010" to "008753-0011-2010" i.e. i need to pad "00" in front of "8753" and "11" i mean the first two strings u can call it.

please advise how i can achieve this in sql server 2005. I need to do this for more then 200 rows.

thanks

+9  A: 
update YourTable
set YourCol =  '00' + STUFF( YourCol,6,0,'00')
WHERE YourCol LIKE '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9][0-9][0-9]'
Martin Smith
+1: Nice; I was working on a monstrosity using CHARINDEX...
OMG Ponies
you are a champion mate
Amit