Home » SQL Server

SSRS option to make capital first letter and rest small letters of a string

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.

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.



10 Answers Found


Answer 1

There is not RS option  but rather .NET option. Write your own report custom code in VB.NET. It's not a hard problem.


Answer 2

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:

Function ProperCase(InputString as String) As String
         Dim i as Integer
         If InputString  <> "" Then
            Mid(InputString , 1, 1) = UCase(Mid(InputString , 1, 1))
            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
            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:


Preview the report.

I hope this is helpful.

Paul Turley [Hitachi Consulting] SQLServerBIBlog.com

Answer 3

When I type  '=Code.ProperCase(Fields!<ColumnName>.Value)' in Expression editor, there is no change in the result



Answer 4

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?




Answer 5

Yeah...... it works when i place in the expression editor like this: =Code.ProperCase("the cow 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.



Answer 6

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?



= LCase(Fields!SomeFieldName.Value)

Also, if this issue is caused by the field format, it will through warning message not the error message.

Hope this helps.



Answer 7

It works with =Code.ProperCase(LCase(Fields!SomeFieldName.Value)).
Thanks a lot.....


Answer 8

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:


If you source string  is all uppercase

Answer 9

Gracias. me sirvio de mucha ayuda

Answer 10

I use this with no custom code in the Code window.  Much easier.





Hi Friends,

                  I want to make StatusCodeName equal to statuscodename in my .cs page..pls suggest me a visual c# code for converting all characters of a string to small letters



I am using the following code to capitilize the first letter theres written

public String ToUpperFirst(string value)
        if (string.IsNullOrEmpty(value))
            return string.Empty;

        char[] letters = value.ToCharArray();   // convert to char array of the string
        letters[0] = char.ToUpper(letters[0]);  // upper case the first char

        return new string(letters); // return the array made of the new char array

I would like it to capatilize every letter after a .(dot) aswell.

any suggestions on how to do that?

Best regards



I have the following code;

DateTime dateResult;
string dateString = e.NewValue as String;
CultureInfo culture = CultureInfo.CreateSpecificCulture("en-US");
if (DateTime.TryParse(dateString, culture, DateTimeStyles.None, out dateResult))
    myVisualElement.Text = dateResult.ToString("dd MMM yy - HH:mm:ss");   

and the output of this code looks like this:

5 Nov 10 - 10:12:11

I would like the month to be all capital letters, so 'Nov' should be 'NOV'.

Does the DateTime.ToString(string) support such a request or do I need to construct my own string using string.format?






I am creating a Word document through the OpenXML SDK 2.0, by opening a document, and then search/replacing all the content controls within it. I give each content control a Tag and Alias, and then put some text within it to a) create the text tag so that I can overwrite it (otherwise I have to add it in the code), and b) make it easier to find within the document when looking over it.


However, when I place text within the control, and the text is in pascal/camel case, it seperates it out into seperate text nodes. e.g. if I place the word 'registeredOffice' within a content control, it will create two seperate runs like so:

          <w:sz w:val=\"28\" />
          <w:szCs w:val=\"24\" />
      <w:r w:rsidR=\"00D74D0C\">
          <w:sz w:val=\"28\" />
          <w:szCs w:val=\"24\" />


why is that?

If I run this search/replace:

SdtElement sdtElement = mainDocumentPart.Document.Descendants<SdtElement>()
                    element =>
                    element.SdtProperties.GetFirstChild<SdtAlias>() != null &&
                    element.SdtProperties.GetFirstChild<SdtAlias>().Val == contentControl).SingleOrDefault();

            if (sdtElement != null)
                sdtElement.Descendants<Text>().FirstOrDefault().Text = "some new text";


Then it replaces the first run so I get this output in the content control:

"some new textOffice"

Any ideas why, or the best way to get round it?




I would like to add a two letter domain with two letter TLD in trusted site in the internet explorer 8 with wildcard.

Like https://*.ch.ch

But this doesn't work. As far I know it's because of the two letter domain.

I can add other none-two domain sites to the trusted site without any problem. I can even add entries like https://*.xy.pl or https://*.xy.gr
We are allowed to register two letter domain in Switzerland, like ch.ch or ag.ch or tg.ch and so on. So I would like to add this two letter domain to the trusted site.

I tried it with a VB-Script or directly in the registry, but that doesn't work either , just the only entry https://ch.ch is recognised as trusted, but not https://www.ch.ch.

Is there a workaround, I mean can I disable this somehow? It's very anoying not be able to work with wildcards, if I have to add all the URL's, I have to add hundreds of entries.

Any help?



Dear All,

Since a while one of our customers receives the following error:
[ArgumentException: An item with the same key has already been added.]
(Full stack trace at the end of post)

For each record we open of the entity letter this error pops up. Since this error apparently indicates there is a problem with a duplicate key (GUID?). But since the error occurs on every record of the entity type letter, this don't looks like the problem.

To be sure, I checked the database if there were more records with the same activityid in the LetterBase table. This wasn't the case.
This took me straight to tracing. For the first time, trace didn't result to more information. Exaclty the same error message is showed in the trace file. Also tried an iisreset, an republish of the entity, recycle of the AppPool.

Hereby the full stack trace:

(Hopefully some can give an explanation for this innoying problem).

Microsoft CRM Error Report:

Error Description:

An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Error Details:

Exception of type 'System.Web.HttpUnhandledException' was thrown.

Full Stack:

[ArgumentException: An item with the same key has already been added.]
  at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
  at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
  at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
  at Microsoft.Crm.Application.Controls.AppCustomization.GetLocalizedValue(XmlNode parentNode, String elementLabelName, String elementChildLabelName)
  at Microsoft.Crm.Application.Controls.AppCustomization.AddCommandBarButton(Client client, XPathNavigator nav, CommandBar cmdBar, String gridId, FormState formState)
  at Microsoft.Crm.Application.Controls.AppCustomization.AddItemsToToolBar(Client client, XPathNavigator nav, MenuBar& menuBar, String gridId, FormState formState)
  at Microsoft.Crm.Application.Controls.AppCustomization.CustomizeToolBar(Client client, MenuBar& menuBar, String nodeName, FormState formState)
  at Microsoft.Crm.Application.Menus.AppFormMenuBar.BuildToolbar()
  at Microsoft.Crm.Application.Menus.AppFormMenuBar.Execute(PrivilegeCheck privilegeCheck, String formName)
  at Microsoft.Crm.Web.Activities.BasicActivityPage.ConfigureMenus()
  at Microsoft.Crm.Application.Controls.AppUIPage.OnPreRender(EventArgs e)
  at System.Web.UI.Control.PreRenderRecursiveInternal()
  at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

[HttpUnhandledException: Exception of type 'System.Web.HttpUnhandledException' was thrown.]
  at System.Web.UI.Page.HandleError(Exception e)
  at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
  at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
  at System.Web.UI.Page.ProcessRequest()
  at System.Web.UI.Page.ProcessRequest(HttpContext context)
  at ASP.ergooptima_activities_letter_edit_aspx.ProcessRequest(HttpContext context)
  at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
  at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

Other Message:

Error Number:

Source File:

Not available
Line Number:

Not available



Time: 14:05:03

Server: ergosql

Request URL:



Hi everyone,

I think this is a little tricky problem, but I need to solve it somehow. 

I have a texbox in my asp.net page.

I want to show all names when a user types in a letter in that textbox, whatever names starting with that letter.

the names are from a list generated by other function, pulled out from active directory.

So for example:

User types in "a" in a textbox then automactically names "aron" "asron" "amanda" in the list shows, and user can select one of those names.

How can I do this?

Thank you for advance :)



Hi i need help to display the Result in the Following Manner i have the Student name Column with value

Student name

tom, jerry  tom@gmail.com

So i need to display the Initials for Firstname and Last name like  T.J as an output...





I stumbled upon this scenario at my work and it is really something I was not expecting. I know that in general SQL itself is not a CASE SENSITIVE language ... so it will not make any difference if i write select *, or SELECT * or SeLEct * ...

But recently I came across a situation where I am required to find results from a table where more than one record exists with just a difference of Captial and Small letter word. Let me explain my problem in detail,

I work for a government client, in one of their table they have list of all state statues and out of them some have exactly same string except in that string some letters are capitalized, e.g.  46b-12 (A) and 46b-12 (a) ... now my question is how can i write a query which can find only record that I search, e.g if I search select desc from statues where code='46b-12 (a)' ... it should find only one record not two.


It seems that the PDF Renderer is only rendering half my letters, especially the ones that are close to the padded area.

It seems that the border (1px black) is right next to a white band (8px white) which flattens the edge of all the letters that are at the end of a sentance.

The border is set to 1px black and padding 8px, background colour = no colour.



How can I generate a random string of 8 numbers and letters?

I've been reading a few articles on the net about making reports either A4 or Letter and I am aware of how to change the layout of the page to be specific for either

The problem we have is that we have some users that use A4 paper, and other users that use Letter size paper.

We would ideally like the user to press the print button from the browser window (note not exported to PDF) and for the report to be printed off on their favourite printer

We have modified the layout to be the lowerst common denominator size (210mm x 279mm).  When we print to our printer which uses A4 paper, it errors because the paper size is odd and needs confirmation to use A4 instead.  I am making the assumption that using a printer with Letter size has the same problem.

We do not want our users to have to deal with errors on their printer every time they try to print a report, it doesn't look good.  We don't want to write 2 versions of each of our reports as that will be time consuming and a maintenance nightmare

Has anyone managed to make SSRS reports printer agnostic or at least be able to print out on either A4 or Letter without additional intervention on the printer?



We are developing reports in SSRS 2008.  When printing from the SSRS report page, we are seeing that that some text is "clumping" together or spaced oddly. I have tried a variety of printers so it's not printer-specific. If you export from the SSRS page to PDF or to Word and then print, everything prints as expected.

Nothing is as good as real text/names/data, but to reproduce, simply create several text boxes with...

I used several common fonts...
Arial, 10 pt (SSRS 2008 default)
Times New Roman, 12 pt (Office 2003 default)
Calibri, 11 pt (Office 2007 default)
Verdana, 11 pt
Tahoma, 11 pt

In the example above, I used normal weight, nothing fancy... If you use bold and underline, which is common for a page/column header or footer, this issue is even more apparent.

It feels similar to the following issue: https://connect.microsoft.com/SQLServer/feedback/details/482312/ssrs-report-font-rendering-issue

A workaround would obviously be to export to PDF and then print, but these are steps that our end users shouldn't have to (and won't want to) put up with to produce reports/invoices/etc. that ultimately go to our clients.




Hi experts,

In my website, where majority of the users are from Norway,I access some values via querystring(eg: email address).Since the members' email ID may contain Latin letters,I am confused and blocked at this level.

My requirements are,

1, I need to access the Latin letters from query string. Is there any thing different from normal query string operations?

2, I need to store these latin Email IDs to  my DB ,which is mysql.Any precaution to be taken while storing latin letters to mysql?

3, I need to show these stored email IDs in my web page.Should I use localization(which I have not used yet) for correctly displaying latin letters in webpage?

Thanks for your reply in advance.


Hi Friends,

Can you help me in this

I want to write a method in C#,  which gives count of letters in a string like " BBCADDZZZ".   For any String of this format.

out put  2 BBs, 1 C,1 A ,2 DD,3ZZZs....



We would like to have the hotkey letter of every clickable item (a button's label, a tab's caption, etc.) be a different colour. Can anyone suggest how this could be done in XAML?  or in code-behind? 

To expand on that what we *really* would like is for all labels to be normal then only when user pushes an "Alt" key then the hotkey letters show up in red. Would be real cool I think, but I haven't a clue how to do it, or if it can be done at all.  Any suggestions gratefully appreciated.



Does anyone know, how to set/get "%delay between letters" to a Custom Animation Effect programmatically ?.


thanks in advance





Is there a way make WDS 4.0 indexing partitions that don't have a letter assigned and mounted as a NTFS folder?

Also it seems WDS doesn't see any hardlinks/junctions either...


I have a storage server with center folder which branched out to all available hard drives/partitions via subfolders and it seems WDS is pretty much useless on that machine as it only sees one central partition...


Any suggestions?

Thank you.



Using UNC paths is NOT preferable, because I'd like to see the "real" path of the found files not UNC path...


SyncToy doesn't seem to handle the drive-letter changing for the backup drive of the archive destination "Right Folder". I am running SyncToy to backup files to an external USB hard-drive from my laptop (Windows XP). When I first created the archive, the USB drive was assigned the letter "F". Since then, depending on what other USB devices are connected to my laptop, the backup diskdrive may connect as drive letter "H", in which case SyncToy doesn't find it and gives error of failure when I run the backup: "Failed to execute folder pair XXX. Could not locate folder F:\xxx\." I request the ability to override the drive letter, or to have it scan more broadly. (I'm using SyncToy I use the "Echo" setting.)  Actually it may handle the drive letter changing between F & G, but not between F & H, I think.


I would like to find a certain sequence of letters in the proper order in database. For example, let's say that I have a column called Names.

With the search string "Ptr" I want to find, for example Peter Petra but not party (as the first two items contain the letter in the ptr order while in party the order is different). So contains will not work in this scenario.



<< Previous      Next >>

Microsoft   |   Windows   |   Visual Studio   |   Sharepoint   |   Azure