SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Capitalize First Letter
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

thehandsomecode
Yak Posting Veteran

Saint Lucia
51 Posts

Posted - 06/06/2008 :  15:47:49  Show Profile  Visit thehandsomecode's Homepage  Click to see thehandsomecode's MSN Messenger address  Reply with Quote
I have a table name filteredcontact and a column named first name.
how do i change the column first name to capitalize the first letter and leave the remaining characters as is.

Compnetsyslc

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

USA
7020 Posts

Posted - 06/06/2008 :  16:01:37  Show Profile  Reply with Quote
Use the sp_rename stored procedure.

You can lookup the exact usage in SQL Server Books Online.



CODO ERGO SUM
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52317 Posts

Posted - 06/07/2008 :  04:26:01  Show Profile  Reply with Quote
quote:
Originally posted by thehandsomecode

I have a table name filteredcontact and a column named first name.
how do i change the column first name to capitalize the first letter and leave the remaining characters as is.

Compnetsyslc


Are you asking for renaming column itself or capitalise the data inside column? If its data you've to change,then use this

SELECT UPPER(LEFT(firstname,1))+SUBSTRING(firstname,2,LEN(firstname)) FROM filteredcontact


If you just wanted to change it only for displaying and do not need the actual data in table to change and

UPDATE filteredcontact
SET firstname=UPPER(LEFT(firstname,1))+SUBSTRING(firstname,2,LEN(firstname))


If you want change to be made to actual data itself
Go to Top of Page

blindman
Flowing Fount of Yak Knowledge

USA
2365 Posts

Posted - 06/07/2008 :  11:06:05  Show Profile  Reply with Quote
quote:
Originally posted by Michael Valentine Jones

Use the sp_rename stored procedure.

You can lookup the exact usage in SQL Server Books Online.



CODO ERGO SUM

Go get another cup of coffee, Michael... ;)

e4 d5 xd5 Nf6
Go to Top of Page

thehandsomecode
Yak Posting Veteran

Saint Lucia
51 Posts

Posted - 06/07/2008 :  16:26:23  Show Profile  Visit thehandsomecode's Homepage  Click to see thehandsomecode's MSN Messenger address  Reply with Quote
quote:
Originally posted by visakh16

quote:
Originally posted by thehandsomecode

I have a table name filteredcontact and a column named first name.
how do i change the column first name to capitalize the first letter and leave the remaining characters as is.

Compnetsyslc


Are you asking for renaming column itself or capitalise the data inside column? If its data you've to change,then use this

SELECT UPPER(LEFT(firstname,1))+SUBSTRING(firstname,2,LEN(firstname)) FROM filteredcontact


If you just wanted to change it only for displaying and do not need the actual data in table to change and

UPDATE filteredcontact
SET firstname=UPPER(LEFT(firstname,1))+SUBSTRING(firstname,2,LEN(firstname))


If you want change to be made to actual data itself





Thank you this worked fine. I needed to change the data itself. we do mass imports at times and the first names and last names arent always what i like to call neat. Thank you

Compnetsyslc
Go to Top of Page

fguiccia
Starting Member

Ireland
3 Posts

Posted - 05/10/2011 :  10:26:27  Show Profile  Reply with Quote
Thanks, very handy :)

Ferruccio Guicciardi
BI Consultant
Go to Top of Page

jimf
Flowing Fount of Yak Knowledge

USA
2869 Posts

Posted - 05/10/2011 :  10:35:22  Show Profile  Reply with Quote
declare @str varchar(10)
set @str = 'adshiou'
select STUFF(@str,1,1,UPPER(left(@str,1)) )

Jim

Everyday I learn something that somebody else already knew
Go to Top of Page

madhivanan
Premature Yak Congratulator

India
22754 Posts

Posted - 05/11/2011 :  06:55:14  Show Profile  Send madhivanan a Yahoo! Message  Reply with Quote
For multiple words, use
http://beyondrelational.com/blogs/madhivanan/archive/2010/07/19/initcap-function.aspx

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

briburrell
Starting Member

USA
1 Posts

Posted - 10/14/2012 :  12:15:30  Show Profile  Reply with Quote

In mysql the update statement is;
update User set firstname = CONCAT( UPPER( LEFT( firstname, 1 ) ) , SUBSTRING( firstname, 2 ) )

quote:
Originally posted by visakh16

quote:
Originally posted by thehandsomecode

I have a table name filteredcontact and a column named first name.
how do i change the column first name to capitalize the first letter and leave the remaining characters as is.

Compnetsyslc


Are you asking for renaming column itself or capitalise the data inside column? If its data you've to change,then use this

SELECT UPPER(LEFT(firstname,1))+SUBSTRING(firstname,2,LEN(firstname)) FROM filteredcontact


If you just wanted to change it only for displaying and do not need the actual data in table to change and

UPDATE filteredcontact
SET firstname=UPPER(LEFT(firstname,1))+SUBSTRING(firstname,2,LEN(firstname))


If you want change to be made to actual data itself




-bb..
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000