0
UPDATE [Customers] 
  SET [Address] = REPLACE([Address],'123456','02')
WHERE [CustomerID] = 4

this code replace 02 on 123456 but i want to change on 2 first digit is change to 023456 can any one help me Thank

Patrick Collins
  • 10,306
  • 5
  • 30
  • 69
  • Are you done try using `substring()`, look over [this doc](http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_substring). – ksugiarto Aug 26 '13 at 09:16

2 Answers2

0
UPDATE [Customers] 
SET [Address] = REPLACE([Address],'12','02')
WHERE [CustomerID] = 4

Assuming 12 don't repeat in the string.

Mihai
  • 26,325
  • 7
  • 66
  • 81
0

Why do you put only '02' characters instead of '023456'? Are you having some situation where you have to put only first two characters, if not try following.

UPDATE [Customers] SET [Address] = REPLACE([Address],'123456','023456')
WHERE [CustomerID] = 4
Chintan
  • 71
  • 1
  • 2
  • 13