Justify for MS SQL Server Reporting Services SSRS


Problem: MS SQL Server Reporting services has no option to justify text.
Idea: Using a T-SQL Function to Format the text as HTML and ad additional white spaces between the words.
Solution:
1. MS Access-Script to measure the widths of each letter. (Will only be needed once!)
For all of you, who do not have MS Access, here is the result for Arial.
1a. Start MS Access
1b. Go to section "Reports" (German: "Berichte")

1c. Click on "Design" (German: "Entwurf")
1d. Customize the Toolbar, Select "Report Design" (German "Berichtsentwurf")

1e. Notice that the German word for "Detail Section" is "Detailbereich". If you work with MS Access in any other language, you have to change the word in the script.
1f. Open the Code-Window.

1g. Select "Detail Section".
1h. Paste the Script in the Code-Window. Check that the "Private Sub Detailbereich_Format" is called correctly.
1i. Close the Code-Window. Select Preview (German "Seitenansicht") (Marked green in the second screen shot)
1j. Go to the Tables Section (German "Tabellen"). There you will find a table "Tabelle2".


2. Prepare the MS SQL Server Database with the following script. (Create scema "report", the functions "true" and "false" and the table "CharacterWidth".)
3. Transfer the result from the MS Access-Table "Tabelle2" to the table CharacterWidth MS SQL Server Table.
4. Create Call the function to justify the text.

Hints:

download all files as zip

Munich, 28.11.2016

R. Spaeth


Change Log:
03.12.2016
MS Access Screenshots added, longer explanation.
09.01.2017 values.txt added.
07.05.2017 Made clear, that the key of the sulution is a T-SQL-function.