> ## Content Index
> Fetch the complete content index at: https://nolongerset.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# VBA to T-SQL via TDD: Step 5
- URL: https://nolongerset.com/vba-to-tsql-via-tdd-step-5/
- Published: 2021-09-12T01:39:51.000Z
- Updated: 2026-05-08T13:02:27.000Z
- Description: Step 5. Create a dummy scalar function in SQL Server
- Author: Mike Wolfe
- Tags: VBA to T-SQL via TDD, #Import 2026-05-20 02:59

*This is Part 5 of [my series](https://nolongerset.com/vba-to-tsql-via-tdd/) on converting a VBA function to a SQL Server scalar function using test driven development. As a proof of concept, I will be [re-implementing the VBA Round function](https://nolongerset.com/trust-but-verify/) (which uses bankers rounding) as a SQL Server scalar function.*

Now that we have our test data in SQL Server, we need to **create a skeleton of our SQL Server scalar function**.

The goal at this point is to match the data types for the inputs and outputs with those of the SQL Server table you created in [Step 3](https://nolongerset.com/vba-to-tsql-via-tdd-step-3/). Do not add any logic to the function yet.

## VBA Round Example

As a reminder, this is the CREATE TABLE script for the SQL Server table I created in Step 3:

```sql
CREATE TABLE dbo.RoundTestData (
 ID int NOT NULL IDENTITY (1,1) PRIMARY KEY CLUSTERED
,NumberToRound sql_variant not null
,NumDigitsAfterDecimal int not null 
,ExpectedValue float not null
)
```

Let's create a skeleton scalar function to match the above fields:

```sql
CREATE FUNCTION dbo.VBA_Round(
    @OriginalVal sql_variant,
    @RoundDigits int
)
RETURNS float
AS
BEGIN
    RETURN 0
END;
```

After executing the above T-SQL statement (\[F5\]), we can verify that the function was successfully created by calling it from within a SELECT statement:

![](https://storage.ghost.io/c/eb/d7/ebd732c1-5f03-4f07-b386-5d08557e15c9/content/images/2021/09/image-41.png)

This dummy version of our *VBA\_Round* function is hard-coded to return 0.

Note that this dummy version of the function returns 0 regardless of the inputs we pass to it. This is an important part of the test-driven development process. DO NOT be tempted to start writing the business logic for your function at this point. Don't worry. We'll get to that part soon.

### Referenced articles

[How to Convert a VBA Function to a SQL Server Scalar FunctionMS Access Developers Can Remove All the Risk From This Complex Process With These 3 Words![](https://nolongerset.com/favicon.png)No Longer SetMike Wolfe![](https://storage.ghost.io/c/eb/d7/ebd732c1-5f03-4f07-b386-5d08557e15c9/content/images/2021/09/caterpillars-2869783_1920.jpg)](https://nolongerset.com/vba-to-tsql-via-tdd/)

[Trust But VerifyWhat Ronald Reagan’s Words Can Teach Us About the Sample Code We Find on the Internet![](https://nolongerset.com/favicon.png)No Longer SetMike Wolfe![](https://storage.ghost.io/c/eb/d7/ebd732c1-5f03-4f07-b386-5d08557e15c9/content/images/2021/09/president-67550_1920.jpg)](https://nolongerset.com/trust-but-verify/)

[VBA to T-SQL via TDD: Step 3Step 3\. Create a temporary test table in SQL Server![](https://nolongerset.com/favicon.png)No Longer SetMike Wolfe![](https://storage.ghost.io/c/eb/d7/ebd732c1-5f03-4f07-b386-5d08557e15c9/content/images/2021/09/Step3-1.png)](https://nolongerset.com/vba-to-tsql-via-tdd-step-3/)