Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid SqlException "syntax near 'GO'": Also split version control object creation script on Unix line endings. #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jspraul
Copy link
Collaborator

@jspraul jspraul commented Feb 7, 2022

I managed to get files with Unix line endings, so the following code doesn't properly break up the script:

var statements = sql.Split(new string[] { "GO\r\n" }, StringSplitOptions.RemoveEmptyEntries);

System.Data.SqlClient.SqlException #102
  Message=Incorrect syntax near 'GO'.
Incorrect syntax near 'GO'.
Incorrect syntax near 'GO'.
Incorrect syntax near 'GO'.
Incorrect syntax near 'GO'.
Incorrect syntax near 'GO'.
Incorrect syntax near 'GO'.
Incorrect syntax near 'GO'.
   at Xnlab.SQLMon.Common.SqlHelper.ExecuteNonQuery(String sql, ServerInfo server) in src\Common\SQLHelper.cs:line 70
   at Xnlab.SQLMon.UI.Monitor.<SetVersionControl>b__157_0(String s) in src\UI\Monitor.cs:line 1660
   at Xnlab.SQLMon.Common.Extensions.ForEach[T](IEnumerable`1 source, Action`1 action) in src\Common\Extensions.cs:line 73
   at Xnlab.SQLMon.UI.Monitor.SetVersionControl(Boolean enable) in src\UI\Monitor.cs:line 1660
   at Xnlab.SQLMon.UI.Monitor.OnSetVersionControlClick(Object sender, EventArgs e) in src\UI\Monitor.cs:line 3950

Tested with Visual Studio 2019 on Windows 10.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant