| Author |
Topic  |
|
|
thehandsomecode
Yak Posting Veteran
Saint Lucia
51 Posts |
Posted - 06/06/2008 : 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)
USA
7007 Posts |
Posted - 06/06/2008 : 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
India
48073 Posts |
Posted - 06/07/2008 : 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 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
|
 |
|
|
blindman
Flowing Fount of Yak Knowledge
USA
2365 Posts |
Posted - 06/07/2008 : 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
Saint Lucia
51 Posts |
Posted - 06/07/2008 : 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 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 |
 |
|
|
fguiccia
Starting Member
Ireland
3 Posts |
Posted - 05/10/2011 : 10:26:27
|
Thanks, very handy :)
Ferruccio Guicciardi BI Consultant |
 |
|
|
jimf
Flowing Fount of Yak Knowledge
USA
2868 Posts |
Posted - 05/10/2011 : 10:35:22
|
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 |
 |
|
|
madhivanan
Premature Yak Congratulator
India
22469 Posts |
|
|
briburrell
Starting Member
USA
1 Posts |
Posted - 10/14/2012 : 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 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.. |
 |
|
| |
Topic  |
|