VB例程解析SQL字符串并获取字段名称 [英] VB routine to parse SQL string and get the field names

查看:121
本文介绍了VB例程解析SQL字符串并获取字段名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


我知道这对你们来说很容易,但我不是VB的开发人员。我的老板

只是想让我在Access

DB中生成所有查询的映射。所以我设法创建了一些子程序来获取查询。我只需要
现在需要解析SQL字符串并获取字段名称。然后导入

到Excel。


输入:

选择field1,field2 FROM Table1


输出:

QUERY1

------

Table1.Field1

表1。 Field2


当然样本是一个简单的sql。例程应该处理复杂的

sql'。


TIA。

ross

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

推荐答案



" PC数据表" <无**** @ nospam.spam>在消息中写道

新闻:Bx **************** @ newsread1.news.pas.earthli nk.net ...

"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.


如果你想做得对,它实际上并不容易 - 这真是太难了。

但是,如果你对90%的automnatic感到满意,并且手工完成剩下的工作,那么它就可以很简单地使用它。


基本上,使用InStr查找SELECT单词的位置,然后再次查找

下一个FROM,使用Mid
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

解析出该段的字符串

,然后使用Split

来获取用逗号分隔的项目数组。


2004年12月10日15:52:47 -0800,< a href =mailto:te ** @ i-vibe.com> te ** @ i-vibe.com 写道:
, 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:
大家好,

我知道这对你们来说很容易,但我不是VB的开发人员。我的老板
只是想让我在Access
DB中生成所有查询的映射。所以我设法创建了一些子程序来获取查询。我现在需要解析SQL字符串并获取字段名称。然后将其导入Excel。

输入:
选择field1,field2 FROM Table1

输出:
QUERY1
- -----
Table1.Field1
Table1.Field2

当然样本是一个简单的sql。例程应该处理复杂的sql'。

TIA。
ross
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






这篇关于VB例程解析SQL字符串并获取字段名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆