I have a DB script that I have read from a file and take that script in a string variable. The file contains multiple DB scripts to execute. Now i want to break that large string into sub-strings as my string found GO keyword.
I am using
myString.split("Go");
--Note: "Go" keyword is not case sensitive for executing a script it can be "go", "Go", "GO" or anything
but it is not working for me because there are some tables or database names that contains GO and the script split there as well.
here is my script:
---- Database New_Db_Gomsle
IF NOT EXISTS (SELECT * FROM user_table_gomsle WHERE USER id = 1124)
BEGIN
ALTER TABLE user_table_gomsle
ADD user_img varchar(MAX)
END
Go
--- Database Angolifie_Db
IF NOT EXISTS (SELECT * FROM user_table_Angolifie WHERE USER id = 1124)
BEGIN
ALTER TABLE user_table_gomsle
ADD user_img varchar(MAX)
END
GO
ALTER TABLE gotham_Accessories
ALTER COLUMN stationary_count INT
go
Like there Exits 'Go' keywords in script Comments, table names, database names.
I am Expecting result like
string[] myQueryArray = new string[10];
myQueryArray[0] = "---- Database New_Db_Gomsle
IF NOT EXISTS (SELECT * FROM user_table_gomsle WHERE USER id = 1124)
BEGIN
ALTER TABLE user_table_gomsle
ADD user_img varchar(MAX)
END
Go"
myQueryArray[1] = " --- Database Angolifie_Db
IF NOT EXISTS (SELECT * FROM user_table_Angolifie WHERE USER id = 1124)
BEGIN
ALTER TABLE user_table_gomsle
ADD user_img varchar(MAX)
END
GO"
myQueryArray[2] = "ALTER TABLE gotham_Accessories
ALTER COLUMN stationary_count INT
go"
but i am not getting the result that way due to 'Go' keyword in db name, table name, comment.