How do I run large SQL scripts that contain many keywords, including “GO” using C#?

前端 未结 3 1072
心在旅途
心在旅途 2020-12-21 14:04

I\'m creating a web application that serves as a front end to do SQL Replication.

I have many scripts stored in the properties of the program. Let\'s use the first o

3条回答
  •  一向
    一向 (楼主)
    2020-12-21 14:25

    The GO command is not an SQL command, it's a command in SQL Management Studio. It separates batches in a script.

    To run the script as SQL, split it on "GO" and execute each string by itself.

    (You might want to use a regular expression like \bGO\b or \sGO\s to do the split, so that you catch only occurances that is not part of a word, if you would happen to have an identifier that contains "go".)

提交回复
热议问题