Solved

formating in sql 2008

Posted on 2013-05-22
6
193 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 12

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 12

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 12

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
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
LVL 12

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

Microsoft Certification Exam 74-409

VeeamĀ® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

867 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now