Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to turn a TEXT field value to PROPER CASE

Status
Not open for further replies.

Guest_imported

New member
Joined
Jan 1, 1970
Messages
0

Is there a way to turn the value entered into an HTML text box to PROPER CASE when it is inserted into the database, and by PROPER CASE I mean the first letter CAPS and the rest LOWER CASE. I know it can be done using javascript, but I was wondering if there is any other way to do it.
Thanks for your help.
Kash
 
You can use the built in string functions UPPER and LOWER in conjunction with LEFT and RIGHT.

Example: Make 1st letter uppercase and other letters lowercase
Select Upper(Left(value,1))+Lower(Right(value,len(value)-1))

---------------------------------

Neil Pike has created a more robust proper case SQL Stored Procedure. The T-SQL code is listed in the SQL Server FAQ at the following link.


After copying the code and creating your SP, test it with the following T-SQL code.

Declare @name varchar(255)
Set @name='SANDRA g. richardson'
Exec sp_proper @name output
Print @name

The result should be Sandra G. Richardson.

---------------------------------
Check the SQL Server FAQ - It is a great resource.

Terry L. Broadbent
FAQ183-874 contains tips for posting questions in these forums.
NOTE: Reference to the FAQ is not directed at any individual.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top