1

i have one column with this values, i want this column have x-xxxxxx-xxx-xxx template,x is number

## codel ##
1-829549-305-117
1-1196585-305-119
119.305.1983984.1 // this record not custom template
1-224594-305-121
1-1999987-305-121
122.306.113416.1 // this record not custom template
1-158059-305-122
1-1083888-305-126

for convert Records that do not have the default format is :

example :

    DECLARE @myvar varchar(20);  
SET @myvar = '119.305.1983984.1';  

SELECT CONCAT(PARSENAME(@myvar,1),'-',PARSENAME(@myvar,2),'-',PARSENAME(@myvar,3),'-',PARSENAME(@myvar,4)) 

result must be :

## codel ##
1-829549-305-117
1-1196585-305-119
1-1983984-305-119 // this record fixed
1-224594-305-121
1-1999987-305-121
1-113416-306-122 // this record fixed
1-158059-305-122
1-1083888-305-126

thanks for read my question

Abcd Efgh
  • 25
  • 4
  • simply create a function of this example code with parameter and use it in update or select query to get the desired result. – Muhammad Waheed Jan 17 '19 at 10:27
  • simply create a function of this example code with parameter and use it in update or select query to get the desired result. – Muhammad Waheed Jan 17 '19 at 10:27
  • 1
    You were asked multiple questions in the comments to your prior question. Rather than creating an exact duplicate of your existing question, and not answering the questions the volunteers here had, please address the comments in your original question by [editing](https://stackoverflow.com/posts/54224713/edit) it. If you then want to make people aware of the amendments, you can mention them in the comments why using @{Username} (Obviously replace {Username} with the user's actual username for mentioniong). For example, for myself it would be @Larnu . – Thom A Jan 17 '19 at 10:32

0 Answers0