When I execute a query " select ('NILESH') " in sql server 2008 it gives the output as NILESH.
But I want oupput as there should be only first letter capital rather than all the letters like I want o/p should be like " Nilesh " i.e. only first letter capital and others are small. How to write query for this.
Want output as follwos
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Sanjeeb LenkaRank #301 · 8.3K reputationPosted Sep 17, 2013, 3:20 AM EDT
try this
DECLARE @name nvarchar(20)='NILESH'
SELECT UPPER(LEFT(@name,1))+LOWER(SUBSTRING(@name,2,LEN(@name)))
Iftikar HussainRank #423 · 5.9K reputationPosted Sep 17, 2013, 3:21 AM EDT
Try like this
select UPPER(LEFT('NILESH',1))+lower(SUBSTRING('NILESH',2,len('NILESH')))
Regards,
Iftikar
Shankar MRank #874 · 2.5K reputationPosted Sep 17, 2013, 3:26 AM EDT
There is no Initcap function in Sqlserver as in Oracle. Instead we can write a custom function to achieve the same functionality.
DECLARE @NAME VARCHAR(10)
SET @NAME = 'NILESH'
SELECT UPPER(SUBSTRING(@NAME,1,1)) + LOWER(SUBSTRING(@NAME,2,LEN(@NAME)))