Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Splitting FullName Column

The column lists the name as "Doe, John A"
I need this to be separated into 2 columns.

Last Name | First Name
Doe       | John A

Heres the code I have but I need it to remove the "," that it outputs

LTRIM(RTRIM(SUBSTRING(Staff_Name, 0, CHARINDEX(' ', Staff_Name)))) As [Physician First Name],
 LTRIM(RTRIM(SUBSTRING(Staff_Name, CHARINDEX(' ', Staff_Name)+1, 8000)))As [Physician Last Name]

Here is what the code is currently outputting:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Last Name | First Name    
Doe,      | John A

>Solution :

I think you can use , instead of space to remove the comma.

CHARINDEX(',', Staff_Name)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading