Separar los valores de la columna de datos
Frecuentes
Visto 70 veces
2 Respuestas
2
if you are using oracle database then it should be as follows:
select replace('I~A~G~S','~',' ') as x from dual;
select replace(<fieldname>,'~',' ') from <tablename>
as for the question of splitting the string in different rows please check the below query.
SELECT trim(regexp_substr(replace('I~A~G~S','~',','), '[^,]+', 1, LEVEL)) str_2_tab
FROM dual
CONNECT BY LEVEL <= regexp_count(replace('I~A~G~S','~',','), ',')+1;
respondido 27 nov., 13:06
you are welcome. if the answer has answered all you questions, please mark as answered. thnxs - Shann
can we get I~A~G~S into different- different variables like income = I, Age=A, Gender=G and State=S; - Java_Alerta
2
declare @s varchar(10)
set @s='I~A~G~S'
select replace(@s,'~',' ')
es updated question
create table #vij11 (s varchar(100))
insert into #vij11(s) values ('I~A~G~S')
SELECT
Split.a.value('.', 'VARCHAR(100)') AS String
FROM (SELECT [s],
CAST ('<M>' + REPLACE([s], '~', '</M><M>') + '</M>' AS XML) AS String
FROM #vij11) AS A CROSS APPLY String.nodes ('/M') AS Split(a);
respondido 27 nov., 13:06
Could i get the same as values in different-2 row. like I in first row then A in 2nd row. - Java_Alerta
what you mean ? like I A G S *2 - vhadalgi
FIRST ROW I, SECOND ROW A , THIRD ROW G , FOURTH ROW S - Java_Alerta
@Java_Alert i have updated the answer above for splitting the string in different rows. please check - Shann
can we get I~A~G~S into different- different variables like income = I, Age=A, Gender=G and State=S; - Java_Alerta
No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas database plsql or haz tu propia pregunta.
is this what you are expecting? select replace('I~A~G~S','~',' ') as x from dual; you can use replace function in oracle. you replace the ~ with with space. - Shann
posible duplicado stackoverflow.com/questions/18770581/… - Noel