Solved

formating in sql 2008

Posted on 2013-05-22
6
194 Views
Last Modified: 2013-05-22
Hello,
I need to change the capitals from this
Lastname         Firstname
SMITH              KEITH KIRKWOOD
PHIPPS              OWEN CHARLES
BERENDSE       ANTONIA GERRANDINA
TAYLOR              DOREEN MARGARET
MURRELL              NANCY BERYL
TUSTIN              LILY

to this
Lastname         Firstname
Smith                Keith Kirwood
Phipps              Owen Charles
Berendse          Antonia Gerrandina
Taylor                Doreen Margaret
Murrell              Nancy Beryl
Tustin                Lily

The names are consistent I have over 5000 of them, they are in the fields
Lastname and Firstname on my customer table.

I am sure there is a script to do this
0
Comment
Question by:Amanda Walshaw
  • 4
  • 2
6 Comments
 
LVL 13

Accepted Solution

by:
Koen Van Wielink earned 500 total points
ID: 39187021
Hi Flyfish,

This should work:

update	yourtable
set			firstname = Replace(Firstname,reverse(left(reverse(firstname),len(firstname)-1)),  reverse(lower(left(reverse(firstname),len(firstname)-1))))
		,	lastname = Replace(Lastname,reverse(left(reverse(Lastname),len(Lastname)-1)),  reverse(lower(left(reverse(Lastname),len(Lastname)-1))))

Open in new window


Best regards,

Kvwielink
0
 
LVL 13

Expert Comment

by:Koen Van Wielink
ID: 39187022
Hi Flyfish,

This should work:

update	yourtable
set			firstname = Replace(Firstname,reverse(left(reverse(firstname),len(firstname)-1)),  reverse(lower(left(reverse(firstname),len(firstname)-1))))
		,	lastname = Replace(Lastname,reverse(left(reverse(Lastname),len(Lastname)-1)),  reverse(lower(left(reverse(Lastname),len(Lastname)-1))))

Open in new window


Best regards,

Kvwielink
0
 
LVL 13

Expert Comment

by:Koen Van Wielink
ID: 39187023
Hi Flyfish,

This should work:

update	yourtable
set			firstname = Replace(Firstname,reverse(left(reverse(firstname),len(firstname)-1)),  reverse(lower(left(reverse(firstname),len(firstname)-1))))
		,	lastname = Replace(Lastname,reverse(left(reverse(Lastname),len(Lastname)-1)),  reverse(lower(left(reverse(Lastname),len(Lastname)-1))))

Open in new window


Best regards,

Kvwielink
0
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 
LVL 13

Expert Comment

by:Koen Van Wielink
ID: 39187026
Sorry about all the triple posts by the way, still haven't figured out how this happens. I'm pressing submit only once.
0
 

Author Comment

by:Amanda Walshaw
ID: 39187052
hmm anyway kvwielink it worked, I remembered after i sent the post, I need to take a break.
Thanks again.l
0
 

Author Closing Comment

by:Amanda Walshaw
ID: 39187054
excellent and too the point
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question