I have a database column of name
name
-----
Sachin tendulkar
Rahul dravid
Now i want to split as the name and last_name update all the rows in database which around 500 data's,
name last_name
---- ----------
Sachin tendulkar
Rahul dravid
Is it possible with sql query?
I have tired the below solution
How to split one column into two columns in SQL Server
Here is mysql-query.
select
case when CHARINDEX('_',name)>0
then SUBSTRING(name,1,CHARINDEX('_',name)-1)
else name end firstname,
CASE WHEN CHARINDEX('_',name)>0
THEN SUBSTRING(name,CHARINDEX('_',name)+1,len(name))
ELSE NULL END as lastname
from user_name
I have tried this method i am getting some error, i don't know how to fixed this errors
Here is database structure