Link to home
Start Free TrialLog in
Avatar of Philippe Renaud
Philippe RenaudFlag for Canada

asked on

SQL Query

Hello, I need help to modify some data inside a table.

I have text in a lot of rows in that format: 1234567890

I need to insert inside each field dots.   I need it to be:   1234.56.78.90

I have some alrady in my table as that format (with dots) wich is fine and I do not need to change them.

for the rest.. i need a modification.  How could I do that inside a SQL query ? any idea?
Avatar of dan_neal
dan_neal
Flag of United States of America image

select case when charindex('.',field) > 0 then field else substring(field,1,4) + '.' + substring(field,5,2) + '.' + substring(field,7,2) + '.' + substring(field,9,2) end as formatted_text from table
Avatar of Philippe Renaud

ASKER

I need to do in update of the table so I guess i just add:

update table set field as

(then your code) ?
ASKER CERTIFIED SOLUTION
Avatar of dan_neal
dan_neal
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial