views:

41

answers:

2

I am currently working on a rather large project in Visual Studio 2008 with a lot of Database-Statements. The Statements are held in strings like this:

string stmt = "SELECT ID, OTHER " +
         "FROM TABLE " +
         "WHERE CONDITION";

I was wondering how to find all Statements via regex. So I am not so good at regex, but maybe someone got any idea? I don't know if it's impossible because of the multilining? Does it work with the search inside Visual Studio?

EDIT to answer of Clement: Well SQL-Statements are not only SELECT-Statements, in my case there are also a lot of UPDATE- and INSERT-Statements. But what if there other eg. CREATE-Statements?

+1  A: 

CTRL + F, Choose "Active Project", and specify "SELECT" as token, no ?

Clement Herreman
+1  A: 

Run a regular expression that uses the '|' operator which acts as an or. An example would be this:

Text To Search "INSERT INTO table; SELECT * FROM table; UPDATE table; DELETE FROM table"

RegEx expression INSERT|SELECT|UPDATE|DELETE

This returns these values along with their index INSERT SELECT UPDATE DELETE

Mentee