-1

What are best practices to perform the Schema-Validation in SQL Server ?

I need to test whether a views, stored-procedure, trigger of function points to an existent and working table (or any other objects) or not, and need to perform this check against all objects in the database. I'd like to avoid people introducing broken code and validate that overall schema which should be in a consistent state before releasing in production.

Shall i do it within unit-testing ? what is the best approach ?

I am using CI / TFS and Visual Studio 2015.

Thanks!

user1611183
  • 311
  • 1
  • 5
  • 12

1 Answers1

1

You can try to use Code Review Policy, which allows you to enforce Code Reviews at checkin time. In this way, you can prevent from checking in the broken code.

Cece Dong - MSFT
  • 29,631
  • 1
  • 24
  • 39
  • Hi Cece, many thanks for your reply .. yes it might be an interesting one to do. However, I am much more interested in a solution where the CI server can check the objects validity itself and get back to users with warnings/errors .. i wonder whether it is possible or not .. – user1611183 Jun 23 '16 at 09:10
  • Using Code Review Policy is an easy way, or you may need to create a listener to listen to the GettingEventHandler event. Once the check-in event is triggered, send out a warning. http://www.almguide.com/2011/12/tfs-server-side-event-handlers/ – Cece Dong - MSFT Jun 23 '16 at 09:32