> ## 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 7
- URL: https://nolongerset.com/vba-to-tsql-via-tdd-step-7/
- Published: 2021-09-15T02:54:46.000Z
- Updated: 2026-05-08T13:02:24.000Z
- Description: Step 7. Execute the test query in SQL Server to verify it fails
- Author: Mike Wolfe
- Tags: VBA to T-SQL via TDD, #Import 2026-05-20 02:59

*This is Part 1 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.*

Red light = FAIL. Green light = PASS.

If you have used test-driven development (TDD) outside of SQL Server, you may be familiar with testing frameworks that show visual red or green icons for failing or passing tests, respectively. For example, here's a screenshot from [Visual Studio's Test Explorer](https://visualstudio.microsoft.com/vs/features/testing-tools/):

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

## Keep It Simple, Stupid

Well, you can forget about that here.

There is no fancy testing framework you need to learn in this case. Instead of red = FAIL and green = PASS, we just have query results. Every row returned from our test query is a **FAILING test**. Every row that exists in the test data table, but that does not get returned from our test query is a **PASSING test.**

Here are the results from running the example test query from [Step 6](https://nolongerset.com/vba-to-tsql-via-tdd-step-6/). 

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

Look! We have 17 failing tests.

Keep in mind, at this point, our *VBA\_Round* scalar function is [hard-coded to return zero](https://nolongerset.com/vba-to-tsql-via-tdd-step-5/) regardless of its inputs. As we implement the **VBA\_Round()* function* and the record count goes to zero, we can be confident it's because the function is doing what we want.

Remember, **if you don't verify your tests fail, you can never really be sure if they are passing.**

### 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 6Step 6\. Build a test query in SQL Server to return failing tests![](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/Step6.png)](https://nolongerset.com/vba-to-tsql-via-tdd-step-6/)

[VBA to T-SQL via TDD: Step 5Step 5\. Create a dummy scalar function 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/Step5.png)](https://nolongerset.com/vba-to-tsql-via-tdd-step-5/)