JElster
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
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
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'"
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
----- 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