Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
SQL SERVER 2012 how to split records in a column separated by delimiter
SELECT a [Column A], SUBSTRING(a, 1, ISNULL(p1 - 1, LEN(a))) [Column B], SUBSTRING(a, p1 + 1, ISNULL(p2, LEN(a) + 1) - p1 - 1) [Column C], SUBSTRING(a, p2 + 1, LEN(a) - p2) [Column D] FROM(VALUES('100.11111.12.16'), ('101.36333'), ('101.REMOTE.01'), ('200.ACTIVE'), ('42170')) a(a) CROSS APPLY(VALUES(NULLIF(CHARINDEX('.', a), 0))) b(p1) CROSS APPLY(VALUES(NULLIF(CHARINDEX('.', a, p1 + 1), 0))) c(p2) CROSS APPLY(VALUES(NULLIF(CHARINDEX('.', a, p2 + 1), 0))) d(p3);
run
|
edit
|
history
|
help
0
Sql
Demo
FirstTable
MSSQL NVARCHAR to INT conversions
TestTable
arithmetic
sssss
Generate xml
Stored Procedure
Select empID whose salary is greater than their managers