-
Breakin last naem, first name from full name
Hello all,
I have a field called name and the data is as John, Smith.
I need to show it as Smith John. How can I do it?
Any help will be appriciated.
Thanks in advance!!
-
There may be a more elegant way to do it, but here is a straightforward method:
declare @name varchar(20)
set @name = 'John, Smith'
SET @name = LTRIM(RTRIM(SUBSTRING(@name, CHARINDEX(',', @name, 1) +1, LEN(@name) - CHARINDEX(',', @name, 1)))) + ' ' + LTRIM(RTRIM(LEFT(@name, CHARINDEX(',', @name, 1) -1)))
SELECT @name
-
Thanks a lot! That works.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|