0

I have an application and this will "install" some stored procedures into a local database.

I want to make a unit test to validate the stored procedures so that the will be valid from SQL Server 2005 and up.

Is there a way to do this with / without SQL Server?

2
  • How do you mean unit-test the stored procedure? What do you expect the tests to give you? Commented Oct 29, 2012 at 14:02
  • The only way to validate them is to install them on SQL Server 2005. Commented Oct 29, 2012 at 14:07

1 Answer 1

1

The Data Dude (Gert Drapers) describes how to use the built-in SQL Server T-SQL parser in your application here:

If you want to only check the validity of the SQL code that you have - this might be a nice way to go, and it doesn't require SQL Server per se to be installed where you run your unit tests.

Sign up to request clarification or add additional context in comments.

4 Comments

Is this parser able to verify compliance with syntax versions and availability of built-in objects and functions? This might be a blind spot.
@usr: the article does show that there is indeed a property SqlVersion which allows you to specify the desired version of T-SQL to be checked against.
Good to know. Still this method does not guarantee that the code works. I think it is more of a superficial syntax check. Dependencies might still fail to bind.
this statement is going wrong is sql server 2005 (but words in sql server 2008) -------------------------------------- INSERT [TABEL1] ( column1, column2) Values( @value1, (select isnull(max(column2)+1,1) from [TABEL1])) -------------------------------------- I want to validate that this query fails for sql server 2005

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.