Executing Sql Scripts with Go Statements as CommandText 30. January 2016 Administrator Technical (0) Here is the code lines for executing the sql script . we may get the errors while executing any string as CommandText that loaded with sql script. This causes due to the GO Statements. I'm providing these code lines to split that Go statements. Hope this is helpful to execute script file with Go Statements. string sqlBatch = string.Empty; script += "\nGO"; SqlCommand cmd = new SqlCommand("", conn); foreach (string line in script.Split(new string[2] { "\n", "\r" }, StringSplitOptions.RemoveEmptyEntries)) { if (line.ToUpperInvariant().Trim() == "GO") { cmd.CommandText = sqlBatch; cmd.ExecuteNonQuery(); sqlBatch = string.Empty; } else { sqlBatch += line + "\n"; } }Sai Venkat - Software Developer