-3

I have this column and rows
enter image description here

I want to split the text in the row into separate columns like this.

enter image description here

0

1 Answer 1

1

In the simple case where every string to split has a non-numeric prefix and ends with a contiguous series of numeric digits you want to return separately, something like the following may suffice:

DECLARE @T table ([Terminal Kodu] varchar(50) NOT NULL);
INSERT @T ([Terminal Kodu]) VALUES ('e-manat1135592398');

SELECT
    [Name] = LEFT(T.[Terminal Kodu], FirstNumeric.position - 1),
    Code = STUFF(T.[Terminal Kodu], 1, FirstNumeric.position - 1, '')
FROM @T AS T
CROSS APPLY 
(
    SELECT position = PATINDEX('%[0123456789]%', T.[Terminal Kodu])
) AS FirstNumeric;

Output:

Name Code
e-manat 1135592398

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.