请问,怎么用sql语句提取数据表名呢?我知道有个:select name from sysobjects where type='U'的语句,但这条语句怎么才能把库中的一个或多个数据表名提取出来呢?我用的是sql server2000,我想把 sql server2000数据库中所有表的表名都提取出来,然后放在窗体上的一个列表框当中。但代码如何写呢?用VB工具,代码怎么写?高手们帮帮忙吧。多谢了!提供下代码或资料。谢了!
调试欢乐多
相应的代码例子太多了,你只要把你的命令语句代替所找到的代码中就行了.
select name from sysobjects where type='U'楼主,这句就是提取所有的表名啊
你把这句在查询分析器里执行一下看看就明白了
go
use test1
go
create table test1(id int,col varchar(10))
create table test2(id int,col2 int)
create table test3(id int,col3 varchar(10))
go
select name from sysobjects where xtype='U'
/*
name
--------------------------------------------------------------------------------------------------------------------------------
test1
test2
test3(3 行受影响)
*/
go
use master
drop database test1
select * from INFORMATION_SCHEMA.TABLES
2000,用这个语句要:select TABLE_NAME from INFORMATION_SCHEMA.TABLES where TABLE_TYPE='BASE TABLE'