如果表存在 [英] if table exist

查看:60
本文介绍了如果表存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



有没有人知道我怎样才能检查ms访问中是否存在一个表?
数据库?我需要一个提供此功能的sql语句。 br />
谢谢。

解决方案

adil写道:


有什么不知道的如何检查ms访问数据库中是否存在表?我需要一个提供此功能的sql语句。
谢谢。




创建一个新模块。添加


公共函数ifTableExists(tblName as String)为布尔值

ifTableExists = False

如果DCount(" ; [Name]",",MSysObjects"," [Name] =''"& tblName&"''")= 1

ifTableExists = True

Endif


结束功能

查询可能会相当慢,具体取决于行数。


" DFS" < nospam@dfs_.com>在新闻中写道:M8ZWf.593


68.204

@ bignews7.bellsouth.net:

adil写道:< blockquote class =post_quotes>
有谁知道如何检查ms访问数据库中是否存在表?我需要一个提供此功能的sql语句。
谢谢。



创建一个新模块。添加

公共函数ifTableExists(tblName as String)为布尔值

ifTableExists = False
如果DCount([Name]",MSysObjects, " [Name] =''"& tblName&"''")= 1 then
ifTableExists = True
Endif

结束功能
在查询中可能相当慢,具体取决于行数。




如果有另一个名为tblName的非表对象怎么办? ?


-

莱尔费尔菲尔德


Hi ,
does any knows how can i check the existence of a table in a ms access
database ?i need a sql statement that provide this function.
Thanks .

解决方案

adil wrote:

Hi ,
does any knows how can i check the existence of a table in a ms access
database ?i need a sql statement that provide this function.
Thanks .



Create a new module. Add

Public Function ifTableExists(tblName as String) as Boolean

ifTableExists = False
If DCount("[Name]","MSysObjects","[Name] = ''" & tblName & "''") = 1 then
ifTableExists = True
Endif

End Function
It might be pretty slow in a query, depending on the # of rows.


"DFS" <nospam@dfs_.com> wrote in news:M8ZWf.593


68.204
@bignews7.bellsouth.net:

adil wrote:

Hi ,
does any knows how can i check the existence of a table in a ms access
database ?i need a sql statement that provide this function.
Thanks .



Create a new module. Add

Public Function ifTableExists(tblName as String) as Boolean

ifTableExists = False
If DCount("[Name]","MSysObjects","[Name] = ''" & tblName & "''") = 1 then
ifTableExists = True
Endif

End Function
It might be pretty slow in a query, depending on the # of rows.



What if there''s another non-table object named tblName?

--
Lyle Fairfield


这篇关于如果表存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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