SQL String value

imfarhan

Board Regular
Joined
Jan 29, 2010
Messages
123
Office Version
  1. 2016
Platform
  1. Windows
Hi,
I have a table called SQLTbl, keeps all SQL of my reports

Field Name Value

QueryCode: D-X1
QueryName: EmployList query
SQLQuery: SELECT empno,ename,job..........

I would like to pulls only string/tables values between "FROM" clause and "WHERE" caluse
Eg:-

Select empno,ename,job, deptno,dname
FROM emp, dept innerjoin dept.deptno.emp.deptno
WHERE dept.dname = "XYZ"

So, from the above query I would like to pull only string value b/w FROMm and WHERE as given below
"FROM emp, dept innerjoin dept.deptno.emp.deptno"

I tried

SELECT INSTR(SQLQuery,"FROM") ????
FROM SQLTbl

I hope it does make sense to you

I thiink I have to use INTR or any other function but don't know how. I would appreciate your help.
Farhan
 
Last edited:

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Assuming your entire SQL string is in cell A1, you could use this formula in VBA to return only the FROM clause into cell B1:

Code:
 Range("B1").Value = Mid(Range("A1").Value, InStr(Range("A1").Value, "FROM"), InStr(Range("A1").Value, "WHERE") - InStr(Range("A1").Value, "FROM"))
 
Upvote 0

Forum statistics

Threads
1,215,527
Messages
6,125,337
Members
449,218
Latest member
Excel Master

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top