SQL Server: Difference Between LEN and DATALENGTH

So what exactly is the difference between the LEN and DATALENGTH functions in SQL Server? They sound similar but they're actually used for two different purposes.
  • The LEN function tells you how many characters are in a string but will exclude any trailing blanks.
  • The DATALENGTH function tells you how many bytes are used to represent an expression.
This means that two string expressions, one with some trailing blanks and one without, could have the same value of LEN but different values for DATALENGTH.
Read More

SSRS: Conditional Formatting for Negative Numbers

If you have an SSRS report and want to apply some conditional formatting to negative values, follow these steps:

  1. Select the value in the Tablix to which you would like to apply conditional formatting.
  2. In the Properties pane, go to the 'Font' group and go to 'Color'. Click the drop-down and choose the last option, 'Expression...'.
  3. The Expression window will open. In the text box at the top enter the following: =Iif(Fields!NameOfYourField.Value<0,"Red","Black")
  4. Click 'OK'.
Of course you can modify this to use any other logic and colours. This simple example will display negative values in red and everything else in black.
Read More