ahmed elbarbary

ahmed elbarbary

  • NA
  • 1.6k
  • 277.9k

How to make User Defined Function split column to two column

Jun 17 2020 6:12 PM

problem

How to make UserDefinedFunction on sql server 2012 split column text to two columns .

first column include text characters as unit measure only and

second column include numbers only in case of integer or decimal etc..?
  1. create table #temp  
  2. (  
  3. columnTextNumbers  nvarchar(50)  
  4. )  
  5. insert into #temp (columnTextNumbers)   
  6. values  
  7. ('3.5A'),  
  8. ('5.50kg'),  
  9. ('35.70kg'),  
  10. ('9m')   
I need to make function split column name columnTextNumbers exist on temp table #temp to
two columns
first column is will be columnTextValues include only units measure .
second column will be columnNumberValues include only numbers if integer or decimal etc ..
so Input will be one value have text and numbers
and output result will be two columns as below :
  1. columnNumberValues     columnTextValues  
  2. 3.5                                  A  
  3. 5.50                                kg  
  4. 35.70                              kg  
  5. 9                                    m  
 

Answers (1)