I have an sql file like this:
Create new-table1 ... As select ..from table1;
Create new-table2 ... As select ..from table2;
Create new-table3 ... As select ..from table3;
And so on..
What I need ro do is append a WHERE clause at the end of each line,so that the queries will be like:
Create new-table1 ... As select ..from table1 where 1000<=(select count(1) from table1);
Create new-table2 ... As select ..from table2 where 1000<=(select count(1) from table2);
Create new-table3 ... As select ..from table3 where 1000<=(select count(1) from table3);
And so on...
Basically new table will be empty for all tables below 1000 rows.
Is there a way I can edit(find&replace) my file using notepad++ so that i can add this where clause?
You may try the following find and replace, in regex mode:
Find: from (\w+);$
Replace: from $1 where 1000 <= (select count(1) from $1);