Sriv
asked on
Split Data in 1 column into 2 columns
In sql how can I split data in 1 column to 2 columns in Sql
Split the data which is before - and after - . some times data could only have single numbers
My data is like this
1
2
1-1
2-1
3-2
Split the data which is before - and after - . some times data could only have single numbers
My data is like this
1
2
1-1
2-1
3-2
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If you're using SQL 2016, you can use the built-in STRING_SPLIT function.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
@Pawan - Congrats to you for stepping up the level of your posts. You have improved the quality of your posts tremendously over the past few months.
@ zephyr_hex - Thank you very much sir for the appreciation !!
Regards,
Pawan
Regards,
Pawan
Another way is to use FOR XML PATH as demonstrated in this article - T-SQL: Normalized data to a single comma delineated string and back. Guessing the above experts comments will work for you as long as there are not any additional requirements not spelled out here.
>@Pawan - Congrats to you for stepping up the level of your posts. You have improved the quality of your posts tremendously over the past few months.
Agreed. You've gone from posting links to rock-star custom T-SQL, which really nails questions..
Hopefully this statement doesn't jinx things, but EE has annual awards that come out and with your point totals lately you're likely in the running for Rookie of the Year.
>@Pawan - Congrats to you for stepping up the level of your posts. You have improved the quality of your posts tremendously over the past few months.
Agreed. You've gone from posting links to rock-star custom T-SQL, which really nails questions..
Hopefully this statement doesn't jinx things, but EE has annual awards that come out and with your point totals lately you're likely in the running for Rookie of the Year.
@Jim Sir-
Thank you very much sir for the appreciation !!
Regards,
Pawan
Thank you very much sir for the appreciation !!
Regards,
Pawan