How to Add Custom Code in SSRS Report - SQL Server Reporting Services (SSRS) Interview Questions and Answers

There could be situations where we don't have built in function/s available in SSRS. we can write our custom functions/code in SSRS Report.

Let's say if we would like to create a function that should be able to accept two string fields and return us concatenated output. For example,This function can be used to concatenate first name and last Name columns. Again this is just to provide you example, We know that concatenation can be done by using expressions.

Here are the steps to add the Custom Code in SSRS.


Step 1: 

Go to Report Tab and then go to Report Properties in SQL Server Data Tools(SSDT)

Step 2:

Write your code in Editor. You can use sample code provided.

Public Function StrConcate(byVal FirstName as string, byVal LastName as string) As string
   dim FullName as String
        FullName = FirstName+" "+LastName 
  return FullName 
End Function 

How to write Custom Code in SSRS report - SSRS Interview Questions and Answers


Step 3: Use the Function we wrote

Let's say if I have two fields called SalePersonFName and SalePersonLName and I would like to concatenate, I can use StrConcate function in expressions as shown below.

How to use Custom Code in SSRS Report - SSRS Interview Questions and Answers