As I don't know If the question was quite understandable, perhaps the problem is quite easy.
I'll give it as an example to show what I want:
I have a .sql file like:
CREATE TABLE Instituição(
//stuff inside
GO
CREATE TABLE Tutor(
//stuff inside
GO
CREATE TABLE Funcao(
//stuff inside
GO
with pretty much a bunch of these code alike, the first thing I want is to look up for "CREATE TABLE (something)", and after that this (something) to be replace in another sentence, which goes to:
IF OBJECT_ID(N'SQL_DB..(something)', N'U') IS NOT NULL
DROP TABLE (something);
GO
to be added before the CREATE TABLE, so the code would be pretty much resulted to:
IF OBJECT_ID(N'SQL_DB..Instituição', N'U') IS NOT NULL
DROP TABLE Instituição;
GO
CREATE TABLE Instituição(
//stuff inside
GO
IF OBJECT_ID(N'SQL_DB..Tutor', N'U') IS NOT NULL
DROP TABLE Tutor;
GO
CREATE TABLE Tutor(
//stuff inside
GO
IF OBJECT_ID(N'SQL_DB..Funcao', N'U') IS NOT NULL
DROP TABLE Funcao;
GO
CREATE TABLE Funcao(
//stuff inside
GO
As I was looking up, the regex code would be like this: find:
CREATE TABLE {:q}
replace:
IF OBJECT_ID(N'SQL_DB..\1', N'U') IS NOT NULL\nDROP TABLE \1;\nGO\nCREATE TABLE \1
But it isn't working, how may I do it properly? Thanks in advance.