Professional Documents
Culture Documents
HomeLibraryLearnDownloadsTroubleshootingCommunityForums
Ask a question
Quick access
Answered by:
7,658
Points
Top 1
Paul Turley
MCC, Partner, MVP
1
4 Paul Turley's threads
Show activity
17
0
Sign in to vote
Hi,
In the 'Name' field of String type is appearing all capital letters. I want to appear it as first
letter is capital and rest all small. If there is space between two characters, then the second
should appear as Caps again.
Ex:
1. PETER Should appear like Peter
2. ALEXANDAR PETER Should appear as Alexander Peter
Is it possible in SSRS or SQL Query ?
I am using SQL Server 2005 SSRS Reporting Services.
Thanks,
Edited by meemkay Thursday, July 09, 2009 8:43 AM
meemkay
20 Points
Answers
3
Sign in to vote
Sure. You could do this in VB or SQL. Here's a quick exmaple of doing this using a VB
function. Open the Report Properties dialog and paste this code into the Code window:
For i = 1 To Len(InputString) - 1
If Mid(InputString, i, 2) = Chr(13) + Chr(10) Then
Mid(InputString, i + 2, 1) = UCase(Mid(InputString, i + 2, 1))
End If
If Mid(InputString, i, 1) = " " Then
Mid(InputString, i + 1, 1) = UCase(Mid(InputString, i + 1, 1))
End If
Next
Return InputString
End If
End Function
In a textbox, right-click. Choose Expression... and type:
=Code.ProperCase("the cow jumped over the moon.")
If you want to apply this logic to a field, enter:
=Code.ProperCase(Fields!SomeFieldName.Value)
Preview the report.
I hope this is helpful.
Paul Turley
SolidQ
(MCC, Partner, MVP)
7,658 Points
Moderator
0
Sign in to vote
Strange, it works fine both with field and string. Could you create three columns for comparison, to see if
there are some differences between three columns?
=Code.ProperCase(LCase(Fields!SomeFieldName.Value))
=Code.ProperCase(cstr(Fields!SomeFieldName.Value))
= LCase(Fields!SomeFieldName.Value)
Also, if this issue is caused by the field format, it will through warning message not the error message.
Raymond-Lee
(MSFT)
13,720 Points
Moderator
0
Sign in to vote
Hi,
It works with
Thanks a lot.....
meemkay
20 Points
All replies
1
Sign in to vote
There is not RS option but rather .NET option. Write your own report custom code in
VB.NET. It's not a hard problem.
Thursday, July 09, 2009 9:17 AM
Reply
|
Quote
Xiaoguang Qiao
Beijing
1,820 Points
3
Sign in to vote
Sure. You could do this in VB or SQL. Here's a quick exmaple of doing this using a VB
function. Open the Report Properties dialog and paste this code into the Code window:
Paul Turley
SolidQ
(MCC, Partner, MVP)
7,658 Points
Moderator
0
Sign in to vote
Hi,
When I type '=Code.ProperCase(Fields!<ColumnName>.Value)' in Expression editor,
there is no change in the result
Thanks,
Thursday, July 09, 2009 9:47 AM
Reply
|
Quote
meemkay
20 Points
0
Sign in to vote
Hi Meemkay,
Using Custom Code as Paul mentioned to achieve that is a good choice, it works fine in my case. Did you get
some warning message? Or when you type the expression like this: =Code.ProperCase("the cow jumped over
the moon."), can you get the respected result?
Regards,
Raymond
Raymond-Lee
(MSFT)
13,720 Points
Moderator
0
Sign in to vote
Hi,
Yeah...... it works when i place in the expression editor
jumped over the moon."),but when i place
=Code.ProperCase(Fields!SomeFieldName.Value), it
doesn't work.
Note: It does not fetch any error messege, indeed the result set is not affected at all.
Thanks,
Monday, July 13, 2009 8:54 AM
Reply
|
Quote
meemkay
20 Points
0
Sign in to vote
Strange, it works fine both with field and string. Could you create three columns for comparison, to see if
there are some differences between three columns?
=Code.ProperCase(LCase(Fields!SomeFieldName.Value))
=Code.ProperCase(cstr(Fields!SomeFieldName.Value))
= LCase(Fields!SomeFieldName.Value)
Also, if this issue is caused by the field format, it will through warning message not the error message.
Raymond-Lee
(MSFT)
13,720 Points
Moderator
0
Sign in to vote
Hi,
It works with
Thanks a lot.....
meemkay
20 Points
Sign in to vote
meemkay, have you seen in the code above the characters are being set to upper case?
So you will probably have to do something like:
=Code.ProperCase(LCase(Fields!SomeFieldName.Value))
If you source string is all uppercase
Tuesday, July 14, 2009 1:36 PM
Reply
|
Quote
_Paddy_
0 Points
0
Sign in to vote
o
6:01 PM
Gbetus
AZABACHE TOUR
0 Points
1
Sign in to vote
I use this with no custom code in the Code window. Much easier.
=strConv(Fields!CUST_NAME.Value,vbProperCase)
Reply
|
Quote
ReportNewb
5 Points
0
Sign in to vote
Well i faced the same issue, but i used ASCII conversion for expression and trim.
example for displaying Dear Melinda, This is what i used,
=Chr(68)+Chr(101)+Chr(97)+Chr(114)+Chr(160)+Left(Fields!
first_name.Value,1)+RTrim(LCase(Right(Fields!first_name.Value,Len(Fields!
first_name.Value)-1)))+Chr(44).
You can find the ASCII code values here,
http://www.web-source.net/symbols.htm
Best of luck. :)
dinesh
Tuesday, July 26, 2011 9:48 PM
Reply
|
Quote
Jake Parker
0 Points
0
Sign in to vote
The above code some times it is working and some times it shows #error why?
suppose ex: name='Narendra Babu '
the above example it shows #error
Friday, January 20, 2012 8:50 AM
Reply
|
Quote
Narukkp
0 Points
0
Sign in to vote
Hi,
Check with StrConv function:
=StrConv("NAREndra Babu ", vbProperCase,NOTHING)
Regards,
Asim Bagwan
Kindly mark the replies as Answers if they help!
Asim Bagwan
Synechron
(Partner)
7,100 Points
0
Sign in to vote
Narukkp
0 Points
0
Sign in to vote
I use this with no custom code in the Code window. Much easier.
=strConv(Fields!CUST_NAME.Value,vbProperCase)
It is working
Friday, January 20, 2012 10:49 AM
Reply
|
Quote
Narukkp
0 Points
0
Sign in to vote
its working
Monday, August 04, 2014 6:20 AM
Reply
|
Quote