I have a simple query that is retrieving a name field from a table. There is NOT an individual first name and last name field; the table value is firstname;lastname. During the SELECT how can I split firstname;lastname into two columns?
Microsoft SQL Server 2008
Last Comment
kbios
8/22/2022 - Mon
dsacker
SELECT LEFT(name, CHARINDEX(';', name) - 1) AS FirstName, SUBSTRING(name, CHARINDEX(';', name) + 1, 80) AS LastNameFROM YourTable
Open in new window
This makes a hard assumption that there will always be that semicolon there.