I want to split the text in the row into separate columns like this.
1 Answer
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 |