• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 272
  • Last Modified:

DB Field format is LName, FName (Single field 'NAME') - need report to read FName, LName - is there a command for that?

I have a report that needs to pull a contact name in the format of FirstName, LastName - the field in the DB is a single field 'NAME' formatted in LastName, FirstName - is there a way to flip the test on each side of the comma and achieve this? All assistance is appreciated.
0
it_stops
Asked:
it_stops
  • 2
2 Solutions
 
amxCommented:
I assume you want the sql :
declare @str1 varchar(50)
declare @str2 varchar(50)
set @str1 = 'FirstName, LastName'
set @str2 = ''
 
select right (@str1, len(@str1) - charindex(',',@str1)) +', '+LEFT ( @str1 , charindex(',',@str1)-1 ) as NewName

Open in new window

0
 
it_stopsAuthor Commented:
Thanks Very Much! Will try it and post results.
0
 
it_stopsAuthor Commented:
this was a great answer
0

Featured Post

Fill in the form and get your FREE NFR key NOW!

Veeam is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now