Author |
Topic |
thehandsomecode
Yak Posting Veteran
51 Posts |
Posted - 2008-06-06 : 15:47:49
|
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)
7020 Posts |
Posted - 2008-06-06 : 16:01:37
|
Use the sp_rename stored procedure.You can lookup the exact usage in SQL Server Books Online.CODO ERGO SUM |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-06-07 : 04:26:01
|
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 thisSELECT 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 andUPDATE filteredcontactSET firstname=UPPER(LEFT(firstname,1))+SUBSTRING(firstname,2,LEN(firstname)) If you want change to be made to actual data itself |
|
|
blindman
Master Smack Fu Yak Hacker
2365 Posts |
Posted - 2008-06-07 : 11:06:05
|
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 |
|
|
thehandsomecode
Yak Posting Veteran
51 Posts |
Posted - 2008-06-07 : 16:26:23
|
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 thisSELECT 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 andUPDATE filteredcontactSET 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 youCompnetsyslc |
|
|
fguiccia
Starting Member
3 Posts |
Posted - 2011-05-10 : 10:26:27
|
Thanks, very handy :)Ferruccio GuicciardiBI Consultant |
|
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2011-05-10 : 10:35:22
|
declare @str varchar(10)set @str = 'adshiou'select STUFF(@str,1,1,UPPER(left(@str,1)) )JimEveryday I learn something that somebody else already knew |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
briburrell
Starting Member
1 Post |
Posted - 2012-10-14 : 12:15:30
|
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 thisSELECT 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 andUPDATE filteredcontactSET firstname=UPPER(LEFT(firstname,1))+SUBSTRING(firstname,2,LEN(firstname)) If you want change to be made to actual data itself
-bb.. |
|
|
|