![]() |
Database »
Database »
SQL Server
Beginner
License: The BSD License
Check Validity of SQL Server Stored Procedures/Views/Functions (updated)By Emil LerchCommand line tool to check validity of objects in SQL Server databases |
SQL, C# 2.0.NET 2.0, Win2K, WinXP, Win2003, Vista, .NET 3.0, .NET 3.5, ADO.NET, SQL 2000, SQL 2005, VS2008
|
|
Advanced Search Add to IE Search |
|
|
|
||||||||||||||||
This is an updated version of the code posted by IPC2000. The following changes have been made:
Please refer to this article for more background on the validation. This is simply a polished version of that piece.
The console executable can be run specifying a /c:<connection string> argument as well as a /v:<verbosity> argument. Verbosity values are:
A new switch, /x, has been added to ask the program to actually run any procedure, function, view it thinks is safe. If CREATE, DROP, INSERT, UPDATE, DELETE, or EXEC/EXECUTE appears in the text of the object it will move on, otherwise, it will add a dummy value for each parameter it finds and execute the object. Since the logic isn't perfect (stored procs can call functions that do bad things), this is turned off by default, but enabling it should generally be safe if the system was coded using best practices. This feature has limited testing behind it - please comment below if you find issues and I'll take a look when I can.
You can also reference the executable directly into NUnit and run the corresponding method. Here's an example C# test method:
[TestFixture]
public class DatabaseValidation
{
[Test]
public void CheckForDatabaseCompilationProblems()
{
Assert.IsTrue(
DatabaseValidator.Validator.DatabaseIsValid(
ConfigurationManager.ConnectionStrings
[MyConnectionString].ConnectionString,
DatabaseValidator.Verbosity.Normal),
"Invalid objects found in the database - Run SqlValidator");
}
}
| You must Sign In to use this message board. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
General
News
Question
Answer
Joke
Rant
Admin
|
PermaLink |
Privacy |
Terms of Use
Last Updated: 19 Sep 2008 Editor: Deeksha Shenoy |
Copyright 2008 by Emil Lerch Everything else Copyright © CodeProject, 1999-2009 Web18 | Advertise on the Code Project |