主 题:各位高手,如何在VB中检测某一个表是否存在?
作 者:hlf
所属论坛:Visual Basic
问题点数:30
回复次数:5
发表时间:2002-1-15 10:29:50
我想在VB中通过代码检测SQL SERVER 2000数库
中某一个表是否存在?应如何做到?
回复贴子:
回复人: ferrytang(水油) (2002-1-15 10:33:00) 得0分
select * from sysobject where type='u' and name='"& tablename &"'
回复人: ilfsm(蜀山刀客) (2002-1-15 10:33:09) 得0分
if exists (select * from sysobjects where id = object_id(N'[dbo].[tableName]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table [dbo].[tableName]如果存在这个表,就删除它(看你自己的意愿了,删不删在你)。
回复人: songyangk(小草) (2002-1-15 10:33:29) 得0分
9494
回复人: fraser01(王晓栋) (2002-1-15 10:36:32) 得0分
select * from information_schema.tables where tablename=...
回复人: crazymens(疯子) (2002-1-15 10:38:10) 得0分
vb:
Select count(*) from [dbname]..[sysobjects] where name='tablename' and type='u') 如果返回的数值>0那么就存在这个表对于临时表的处理稍微有一点不一样,用楼上的方法好一些,这个问题以前有人问过,去查一下以前的铁子[email protected]
作 者:hlf
所属论坛:Visual Basic
问题点数:30
回复次数:5
发表时间:2002-1-15 10:29:50
我想在VB中通过代码检测SQL SERVER 2000数库
中某一个表是否存在?应如何做到?
回复贴子:
回复人: ferrytang(水油) (2002-1-15 10:33:00) 得0分
select * from sysobject where type='u' and name='"& tablename &"'
回复人: ilfsm(蜀山刀客) (2002-1-15 10:33:09) 得0分
if exists (select * from sysobjects where id = object_id(N'[dbo].[tableName]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table [dbo].[tableName]如果存在这个表,就删除它(看你自己的意愿了,删不删在你)。
回复人: songyangk(小草) (2002-1-15 10:33:29) 得0分
9494
回复人: fraser01(王晓栋) (2002-1-15 10:36:32) 得0分
select * from information_schema.tables where tablename=...
回复人: crazymens(疯子) (2002-1-15 10:38:10) 得0分
vb:
Select count(*) from [dbname]..[sysobjects] where name='tablename' and type='u') 如果返回的数值>0那么就存在这个表对于临时表的处理稍微有一点不一样,用楼上的方法好一些,这个问题以前有人问过,去查一下以前的铁子[email protected]
if !Rs.Eof() then
'表tblName存在
select * from sysobject where type='u' and name='"& tablename &"'
回复人: ilfsm(蜀山刀客) (2002-1-15 10:33:09) 得0分
if exists (select * from sysobjects where id = object_id(N'[dbo].[tableName]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table [dbo].[tableName]如果存在这个表,就删除它(看你自己的意愿了,删不删在你)。
回复人: songyangk(小草) (2002-1-15 10:33:29) 得0分
9494
回复人: fraser01(王晓栋) (2002-1-15 10:36:32) 得0分
select * from information_schema.tables where tablename=...回复人: crazymens(疯子) (2002-1-15 10:38:10) 得0分
vb:
Select count(*) from [dbname]..[sysobjects] where name='tablename' and type='u') 如果返回的数值>0那么就存在这个表对于临时表的处理稍微有一点不一样,用楼上的方法好一些,这个问题以前有人问过,去查一下以前的铁子[email protected]
Rs.Open "select * from sysobjects where name='tblDoctors'", aCn, adOpenKeyset, adLockBatchOptimistic
if !Rs.Eof() then
其他的贴子在SQL SERVER2000的查询分析器中可以测试,
在VB中不知如何测试?
其他的贴子在SQL SERVER2000的查询分析器中可以测试,
在VB中不知如何测试?