split string in sql

How can I split a String at "," if it exists?

lastname, firstname

Doe, john

or it could be just name of a business

Bank of American
Who is Participating?
EmesConnect With a Mentor Commented:
declare @names varchar(100)
set @names ='My,Name'

if charindex(',', @names) <> 0
  Select substring(@names,1, charindex(',', @names) -1),
    substring(@names, charindex(',', @names) +1,100)
VBdotnet2005Author Commented:
What if a string does not contain ","?   Bank of American

Command(s) completed successfully.  it does not return anything.
VBdotnet2005Author Commented:
I got it. Thank you
All Courses

From novice to tech pro — start learning today.