If you have no "GO" commands you could use a simple console app and this method:

private static void CheckSyntax(string connectionString, string sql) {
           using (var connection = new SqlConnection(connectionString)) {
               connection.Open();
               string command = string.Format(@"
SET NOEXEC ON

{0}

SET NOEXEC OFF
", sql);
               using (var cmd = new SqlCommand(command, connection)) {
                   cmd.Prepare();
                   cmd.ExecuteNonQuery();
               }
           }
       }


It will throw an exception if there is a syntax error.

With "GO" commands you might still be able to use the "SET NOEXEC ON" stuff using osql.exe, I just don't know what it would return.

Reply via email to