473,379 Members | 1,386 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

VB routine to parse SQL string and get the field names

Hi all,

I know this is easy for you guys but I am not a VB developer. My boss
just wanted me to generate a mapping of all the queries in our Access
DB. So I managed to create some subroutines to get the queries. I just
need now to parse the SQL string and get the field names. Then import
it to Excel.

Input:
Select field1, field2 FROM Table1

Output:
QUERY1
------
Table1.Field1
Table1.Field2

Of course the sample is a simple sql. The routine should handle complex
sql's.

TIA.
ross

Nov 13 '05 #1
13 6468

"PC Datasheet" <no****@nospam.spam> wrote in message
news:Bx****************@newsread1.news.pas.earthli nk.net...
This is a test - please ignore!!!


Thanks for the warning. I don't need to be tested.
Nov 13 '05 #2
If you want to do it right, it's actually not easy at all - it's damn hard.
However, if you can be satisfied with 90% automnatic, and do the rest by hand,
it can be dome pretty simply.

Basically, use InStr to find where the word SELECT is, and then again to find
the next FROM, parse out that piece of the string using Mid$, then use Split
to get an array of items delimited by commas.

On 10 Dec 2004 15:52:47 -0800, te**@i-vibe.com wrote:
Hi all,

I know this is easy for you guys but I am not a VB developer. My boss
just wanted me to generate a mapping of all the queries in our Access
DB. So I managed to create some subroutines to get the queries. I just
need now to parse the SQL string and get the field names. Then import
it to Excel.

Input:
Select field1, field2 FROM Table1

Output:
QUERY1
------
Table1.Field1
Table1.Field2

Of course the sample is a simple sql. The routine should handle complex
sql's.

TIA.
ross


Nov 13 '05 #3
This is a test - please ignore!!!
<te**@i-vibe.com> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...
Hi all,

I know this is easy for you guys but I am not a VB developer. My boss
just wanted me to generate a mapping of all the queries in our Access
DB. So I managed to create some subroutines to get the queries. I just
need now to parse the SQL string and get the field names. Then import
it to Excel.

Input:
Select field1, field2 FROM Table1

Output:
QUERY1
------
Table1.Field1
Table1.Field2

Of course the sample is a simple sql. The routine should handle complex
sql's.

TIA.
ross

Nov 13 '05 #4
PC Datasheet wrote:
This is a test - please ignore!!!


We always ignore your posts anyway Steve :-)

--
This sig left intentionally blank
Nov 13 '05 #5

"PC Datasheet" <no****@nospam.spam> wrote in message
news:Bx****************@newsread1.news.pas.earthli nk.net...
This is a test - please ignore!!!


Thanks for the warning. I don't need to be tested.
Nov 13 '05 #6
If you want to do it right, it's actually not easy at all - it's damn hard.
However, if you can be satisfied with 90% automnatic, and do the rest by hand,
it can be dome pretty simply.

Basically, use InStr to find where the word SELECT is, and then again to find
the next FROM, parse out that piece of the string using Mid$, then use Split
to get an array of items delimited by commas.

On 10 Dec 2004 15:52:47 -0800, te**@i-vibe.com wrote:
Hi all,

I know this is easy for you guys but I am not a VB developer. My boss
just wanted me to generate a mapping of all the queries in our Access
DB. So I managed to create some subroutines to get the queries. I just
need now to parse the SQL string and get the field names. Then import
it to Excel.

Input:
Select field1, field2 FROM Table1

Output:
QUERY1
------
Table1.Field1
Table1.Field2

Of course the sample is a simple sql. The routine should handle complex
sql's.

TIA.
ross


Nov 13 '05 #7
On Dec 10 2004, 06:52 pm, te**@i-vibe.com wrote in
news:11*********************@f14g2000cwb.googlegro ups.com:
Hi all,

I know this is easy for you guys but I am not a VB developer. My boss
just wanted me to generate a mapping of all the queries in our Access
DB. So I managed to create some subroutines to get the queries. I just
need now to parse the SQL string and get the field names. Then import
it to Excel.

Input:
Select field1, field2 FROM Table1

Output:
QUERY1
------
Table1.Field1
Table1.Field2

Of course the sample is a simple sql. The routine should handle complex
sql's.


If you only need to handle SELECT and UNION queries, then instead of
parsing the string, you could open a recordset based on each query, and
enumerate its Fields collection to get the field names. To make it run
faster, open empty recordsets:

SELECT * FROM [query name] WHERE False;

--
remove a 9 to reply by email
Nov 13 '05 #8
Dimitri Furman <df*****@cloud99.net> wrote in
news:Xn****************************@127.0.0.1:
On Dec 10 2004, 06:52 pm, te**@i-vibe.com wrote in
news:11*********************@f14g2000cwb.googlegro ups.com:
I know this is easy for you guys but I am not a VB developer. My
boss just wanted me to generate a mapping of all the queries in
our Access DB. So I managed to create some subroutines to get the
queries. I just need now to parse the SQL string and get the
field names. Then import it to Excel.

Input:
Select field1, field2 FROM Table1

Output:
QUERY1
------
Table1.Field1
Table1.Field2

Of course the sample is a simple sql. The routine should handle
complex sql's.


If you only need to handle SELECT and UNION queries, then instead
of parsing the string, you could open a recordset based on each
query, and enumerate its Fields collection to get the field names.
To make it run faster, open empty recordsets:

SELECT * FROM [query name] WHERE False;


There might be essential tables in the query that are not in the
output.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #9
PC Datasheet wrote:
This is a test - please ignore!!!


We always ignore your posts anyway Steve :-)

--
This sig left intentionally blank
Nov 13 '05 #10
On Dec 10 2004, 06:52 pm, te**@i-vibe.com wrote in
news:11*********************@f14g2000cwb.googlegro ups.com:
Hi all,

I know this is easy for you guys but I am not a VB developer. My boss
just wanted me to generate a mapping of all the queries in our Access
DB. So I managed to create some subroutines to get the queries. I just
need now to parse the SQL string and get the field names. Then import
it to Excel.

Input:
Select field1, field2 FROM Table1

Output:
QUERY1
------
Table1.Field1
Table1.Field2

Of course the sample is a simple sql. The routine should handle complex
sql's.


If you only need to handle SELECT and UNION queries, then instead of
parsing the string, you could open a recordset based on each query, and
enumerate its Fields collection to get the field names. To make it run
faster, open empty recordsets:

SELECT * FROM [query name] WHERE False;

--
remove a 9 to reply by email
Nov 13 '05 #11
Dimitri Furman <df*****@cloud99.net> wrote in
news:Xn****************************@127.0.0.1:
On Dec 10 2004, 06:52 pm, te**@i-vibe.com wrote in
news:11*********************@f14g2000cwb.googlegro ups.com:
I know this is easy for you guys but I am not a VB developer. My
boss just wanted me to generate a mapping of all the queries in
our Access DB. So I managed to create some subroutines to get the
queries. I just need now to parse the SQL string and get the
field names. Then import it to Excel.

Input:
Select field1, field2 FROM Table1

Output:
QUERY1
------
Table1.Field1
Table1.Field2

Of course the sample is a simple sql. The routine should handle
complex sql's.


If you only need to handle SELECT and UNION queries, then instead
of parsing the string, you could open a recordset based on each
query, and enumerate its Fields collection to get the field names.
To make it run faster, open empty recordsets:

SELECT * FROM [query name] WHERE False;


There might be essential tables in the query that are not in the
output.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #12
On Dec 11 2004, 11:53 am, "David W. Fenton" <dX********@bway.net.invalid>
wrote in news:Xn**********************************@24.168.1 28.86:
Dimitri Furman <df*****@cloud99.net> wrote in
news:Xn****************************@127.0.0.1:
On Dec 10 2004, 06:52 pm, te**@i-vibe.com wrote in
news:11*********************@f14g2000cwb.googlegro ups.com:
I know this is easy for you guys but I am not a VB developer. My
boss just wanted me to generate a mapping of all the queries in
our Access DB. So I managed to create some subroutines to get the
queries. I just need now to parse the SQL string and get the
field names. Then import it to Excel.

Input:
Select field1, field2 FROM Table1

Output:
QUERY1
------
Table1.Field1
Table1.Field2

Of course the sample is a simple sql. The routine should handle
complex sql's.


If you only need to handle SELECT and UNION queries, then instead
of parsing the string, you could open a recordset based on each
query, and enumerate its Fields collection to get the field names.
To make it run faster, open empty recordsets:

SELECT * FROM [query name] WHERE False;


There might be essential tables in the query that are not in the
output.


True, but the requirement, as I understand it, is to document the output,
not the entire query:
I just need now to parse the SQL string and get the
field names.


--
remove a 9 to reply by email
Nov 13 '05 #13
On Dec 11 2004, 11:53 am, "David W. Fenton" <dX********@bway.net.invalid>
wrote in news:Xn**********************************@24.168.1 28.86:
Dimitri Furman <df*****@cloud99.net> wrote in
news:Xn****************************@127.0.0.1:
On Dec 10 2004, 06:52 pm, te**@i-vibe.com wrote in
news:11*********************@f14g2000cwb.googlegro ups.com:
I know this is easy for you guys but I am not a VB developer. My
boss just wanted me to generate a mapping of all the queries in
our Access DB. So I managed to create some subroutines to get the
queries. I just need now to parse the SQL string and get the
field names. Then import it to Excel.

Input:
Select field1, field2 FROM Table1

Output:
QUERY1
------
Table1.Field1
Table1.Field2

Of course the sample is a simple sql. The routine should handle
complex sql's.


If you only need to handle SELECT and UNION queries, then instead
of parsing the string, you could open a recordset based on each
query, and enumerate its Fields collection to get the field names.
To make it run faster, open empty recordsets:

SELECT * FROM [query name] WHERE False;


There might be essential tables in the query that are not in the
output.


True, but the requirement, as I understand it, is to document the output,
not the entire query:
I just need now to parse the SQL string and get the
field names.


--
remove a 9 to reply by email
Nov 13 '05 #14

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: fowlertrainer | last post by:
Hi ! Sorry, but zope@zope.org is not send mails to me... So I trying with that list... 1.) I want to use query-string, and post datas in combined dictionary. I have a page that I must...
3
by: Ken Bush | last post by:
How can I write an update query that removes part of a field? Like if I have a field with values such as 8/3/68 (a birthday obviously) and I need to put values in a new column but I need...
1
by: temp | last post by:
Hi all, I know this is easy for you guys but I am not a VB developer. My boss just wanted me to generate a mapping of all the queries in our Access DB. So I managed to create some subroutines to...
12
by: MLH | last post by:
I have a bunch of what you see below in a field named CSZ. I want to parse it the easiest way possible. I just don't know where to start... CSZ Anchorage AK 99518-3051 Anchorage AK 99518-3051...
11
by: hoopsho | last post by:
Hi Everyone, I am trying to write a program that does a few things very fast and with efficient use of memory... a) I need to parse a space-delimited file that is really large, upwards fo a...
29
by: gs | last post by:
let say I have to deal with various date format and I am give format string from one of the following dd/mm/yyyy mm/dd/yyyy dd/mmm/yyyy mmm/dd/yyyy dd/mm/yy mm/dd/yy dd/mmm/yy mmm/dd/yy
7
by: Bob Darlington | last post by:
I'm using the following routine to call UpdateDiary() - below: Private Sub Form_BeforeUpdate(Cancel As Integer) On Error GoTo Form_BeforeUpdate_Error Call UpdateDiary(Me!TenantCounter,...
5
by: portCo | last post by:
Hi there, I am re-organizing the database. We used to have field 'names' in our table for our first name and last name. However, I want to have those names in different field. FYI, I have two...
16
by: Chuck | last post by:
Please help me correct the statements in sub "BoundData" The following sub is in a module. Everything runs with no error messages, however,data is not reaching the text box. Data is being...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.