How to write automated tests for SQL queries?

Posted by James on Stack Overflow See other posts from Stack Overflow or by James
Published on 2014-05-07T18:33:06Z Indexed on 2014/06/06 21:27 UTC
Read the original article Hit count: 328

The current system we are adopting at work is to write some extremely complex queries which perform multiple calculations and have multiple joins / sub-queries. I don't think I am experienced enough to say if this is correct or not so I am agreeing and attempting to function with this system as it has clear benefits.

The problem we are having at the moment is that the person writing the queries makes a lot of mistakes and assumes everything is correct. We have now assigned a tester to analyse all of the queries but this still proves extremely time consuming and stressful.

I would like to know how we could create an automated procedure (without specifically writing it with code if possible as I can work out how to do that the long way) to verify a set of 10+ different inputs, verify the output data and say if the calculations are correct.

I know I could write a script using specific data in the database and create a script using c# (the db is SQL Server) and verify all the values coming out but I would like to know what the official "standard" is as my experience is lacking in this area and I would like to improve.

I am happy to add more information if required, add a comment if necessary. Thank you.

Edit: I am using c#

© Stack Overflow or respective owner

Related posts about c#

Related posts about sql