VBA to T-SQL via TDD: Step 4

Step 4. Use the results of your Access query to populate the test table

VBA to T-SQL via TDD: Step 4

This is Part 4 of my series 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 (which uses bankers rounding) as a SQL Server scalar function.

After building a "test table population query" in Step 2 and creating the test table structure itself in Step 3, populating the SQL Server test table is a simple matter of copy and paste.

  1. Execute the test table population query
  2. Press Ctrl + A to select all the rows in the query
  3. Press Ctrl + C to copy the rows to the clipboard
  4. Create a New Query window in your development database in SSMS
  5. Press Ctrl + V to paste the rows from the clipboard (delete or comment out the header row)
  6. Press F5 to execute the T-SQL statements
Step 1. The test table population query
Step 2 & 3. Select all ([Ctrl] + [A]) then copy ([Ctrl] + [C])
Step 4. Create a New Query
Step 5. Paste ([Ctrl] + [V])
Step 6. Execute the INSERT INTO statements ([F5])

Referenced articles

How to Convert a VBA Function to a SQL Server Scalar Function
MS Access Developers Can Remove All the Risk From This Complex Process With These 3 Words
Trust But Verify
What Ronald Reagan’s Words Can Teach Us About the Sample Code We Find on the Internet
VBA to T-SQL via TDD: Step 2
Step 2. Build a “test table population query” in Microsoft Access
VBA to T-SQL via TDD: Step 3
Step 3. Create a temporary test table in SQL Server

External references

Download SQL Server Management Studio (SSMS) - SQL Server Management Studio (SSMS)
Download the latest version of SQL Server Management Studio (SSMS).

All original code samples by Mike Wolfe are licensed under CC BY 4.0