473,785 Members | 3,388 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 6527

"PC Datasheet" <no****@nospam. spam> wrote in message
news:Bx******** ********@newsre ad1.news.pas.ea rthlink.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.Field 1
Table1.Field 2

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******** *************@f 14g2000cwb.goog legroups.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******** ********@newsre ad1.news.pas.ea rthlink.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.Field 1
Table1.Field 2

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******** *************@f 14g2000cwb.goog legroups.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*****@cloud9 9.net> wrote in
news:Xn******** *************** *****@127.0.0.1 :
On Dec 10 2004, 06:52 pm, te**@i-vibe.com wrote in
news:11******** *************@f 14g2000cwb.goog legroups.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

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

Similar topics

1
2123
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 access with special query string, but it have post datas.
3
4747
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 everything after and including the final / removed to end up with simply 8/3
1
537
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 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
12
2810
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 Juneau AK 99801-6917 Palmer AK 99645 Kenai AK 99611-1753
11
3621
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 million lines. b) I need to store the contents into a unique hash. c) I need to then sort the data on a specific field. d) I need to pull out certain fields and report them to the user.
29
2909
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
2420
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, "sfTenantDetailsOther") Exit Sub Form_BeforeUpdate_Error: MsgBox "Error " & Err.Number & " (" & Err.Description & ") " _ & "in procedure Form_BeforeUpdate in Line " & Erl & "."
5
4354
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 different tables in different databases. The A database contains A table with 'names" field. The B database contains B table with 'fname' and 'lname' I want to copy data A table to B table.
16
2451
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 appended to WorkingTable but not filtered by value in text box. If I input data into the text box, it gets deleted by the sub routine, indicating that ctla.ItemData(varItm) is null. Sub BoundData() Dim frm As Form
0
9643
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10319
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10087
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8971
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7496
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4046
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.