Link to home
Start Free TrialLog in
Avatar of JElster
JElsterFlag for United States of America

asked on

C# Help with Substring - Need to return just the WHERE clause of SQL Statement

I have 100's of SQL statements.. I need a function to return just the WHERE portion of the SQL statement - Each Statement has an ORDER at the end which I don't need

SELECT * FROM EMPLOYEES WHERE EMPLOYEE.LAST_NAME = 'JONES' ORDER BY LAST_NAME

           "EMPLOYEE.LAST_NAME = 'JONES'"

SELECT * FROM CUSTOMERS WHERE CUSTOMER.NAME = 'Abc' AND CUSTOMER.NUMBER > 101  ORDER BY CUSTOMER.NUMBER  

   "CUSTOMER.NAME = 'Abc' AND CUSTOMER.NUMBER > 101"    


Select rtrim(lastname)+', '+rtrim(firstname) as Name, * from cUSTOMER where (Inactive =' '  And  RepNo <  'P00001 '   And   CurrentYear = ' '  And  FutureTermination = ' '  and deleted = 0) order by lastname, firstname  

 "(Inactive =' '  And  RepNo <  'P00001 '   And   CurrentYear = ' '  And  FutureTermination = ' '  and deleted = 0)


Needs to also consider the case of 'WHERE' and 'ORDER'

Thanks
Avatar of ryerras
ryerras

i do not understand. The following statements are contradictory

----- Each Statement has an ORDER at the end which I don't need
----- Needs to also consider the case of 'WHERE' and 'ORDER'
Let us know what you are looking for
Avatar of JElster

ASKER

Just need the where part ,not the order by... Some of the statements are in upper case and others not..

For Example:

SELECT * FROM EMPLOYEES WHERE EMPLOYEE.LAST_NAME = 'JONES' ORDER BY LAST_NAME


I just need return the following:

           "EMPLOYEE.LAST_NAME = 'JONES'"
ASKER CERTIFIED SOLUTION
Avatar of ryerras
ryerras

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial