如果表存在 [英] if table exist
问题描述
有没有人知道我怎样才能检查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屋!