怎么能一条一条地取出一个数据库中所有的表名
select name from (
select id=identity(int),name into #t from mydb.dbo.sysobjects where xtype='U' and status>=0 order by name)
where id=2
我写的,但是不对。
意图是每次改变id=x,取出不同的表名
问题点数:0、回复次数:18Top
1 楼btut2004(养鱼炒股)回复于 2005-04-03 10:09:02 得分 0
upTop
2 楼webcookie()回复于 2005-04-03 15:40:24 得分 0
这么冷清!!Top
3 楼sxycgxj(云中客)回复于 2005-04-03 17:18:11 得分 0
UPTop
4 楼liushuyan12(阳光总在风雨后)回复于 2005-04-04 14:54:35 得分 0
取出一个数据库中所有的表名
select name from sysobjects
where xtype='u'and status>0Top
5 楼webcookie()回复于 2005-04-07 15:36:10 得分 0
一条一条的取.我说的很清楚了.Top
6 楼godenlionx(痴者无心)回复于 2005-04-07 15:46:46 得分 0
初学者,不是太懂,支持(虽然没看懂),关注ing!Top
7 楼xluzhong(Ralph)回复于 2005-04-07 15:59:21 得分 0
create table tbn(name nvarchar(50))
IF EXISTS (SELECT name FROM sysobjects
WHERE name not in(select name from tbn ) AND type = 'u')
SELECT top 1 name FROM sysobjects
WHERE name not in(select name from tbn ) AND type = 'u'
insert into tbn SELECT top 1 name FROM sysobjects WHERE name not in(select name from tbn ) AND type = 'u'Top
8 楼xluzhong(Ralph)回复于 2005-04-07 16:02:23 得分 0
create table tbn(name nvarchar(50))
while EXISTS (SELECT name FROM sysobjects
WHERE name not in(select name from tbn ) AND type = 'u')
begin
SELECT top 1 name FROM sysobjects
WHERE name not in(select name from tbn ) AND type = 'u'
insert into tbn SELECT top 1 name FROM sysobjects WHERE name not in(select name from tbn ) AND type = 'u'
end
drop table tbnTop
9 楼webcookie()回复于 2005-04-09 21:45:37 得分 0
看不懂,另外不要建立一个表那么麻烦吧。Top
10 楼tangzhg(网痴-菜鸟)回复于 2005-04-09 22:17:32 得分 0
我觉得建一个表太大了吧.并且也不一定有那么多的数据量要读取,不如建一个链表,大小限定为多大,再一次读取多少元素,然后用个指针在表中读取数据,直至完成,
当然对链表的数据操作就一定简历些了.Top
11 楼zhang_yzy(六子儿)回复于 2005-04-10 12:48:43 得分 0
select name
from mydb.dbo.sysobjects a
where xtype='U'
and (select count(id)
from mydb.dbo.sysobjects
where id <a.id )=2
Top
12 楼jyk(今天由我来写的代码,明天就让程序自己完成!喜欢编程。和气生财。共同提高。共同进步!)回复于 2005-04-10 16:59:28 得分 0
SELECT o.id, o.name AS TableName, c.name AS colName, t.name AS colKind,
c.length AS colLength, c.isoutparam, c.isnullable, c.[collation], c.tdscollation
FROM dbo.syscolumns c INNER JOIN
dbo.systypes t ON c.xtype = t.xtype INNER JOIN
dbo.sysobjects o ON c.id = o.id
WHERE (o.xtype = 'u')
Top
13 楼Hopewell_Go(好的在后頭﹗希望更好﹗﹗)回复于 2005-04-10 21:25:57 得分 0
select name from sysobjects where xtype='U'Top
14 楼47522341(睡到8:30)回复于 2005-04-11 08:26:10 得分 0
用游标吧;
declare @tableName nvarchar(128)
declare myCursor cursor for
select [name] from sysobjects where xtype = 'U'
open myCursor
fetch next from mycursor into @TableName
while @@Fetch_Status = 0
begin
print @TableName
fetch next from mycursor into @TableName
end
close mycursor
deallocate mycursorTop
15 楼leelong80(小龙)回复于 2005-04-11 09:03:38 得分 0
upTop
16 楼lasthope(学生)回复于 2005-04-11 09:49:32 得分 0
只能用指针Top
17 楼winternet(冬天)回复于 2005-04-11 10:06:21 得分 0
create proc rDatabaseTableName
(
@dbname nvarchar(1000)
)
as
exec ('use '+ @dbname)
declare @tb nvarchar(100)
declare cr cursor for
select Name from sysobjects where xtype='U' and name not like 'dt%'
open cr
fetch next from cr into @tb
while @@fetch_Status=0
begin
print @tb
fetch next from cr into @tb
end
close cr
deallocate cr
goTop
18 楼webcookie()回复于 2005-04-14 11:01:55 得分 0
只想用一条语句做到,像我写的那样。Top
相关问题
- 请问Access 中是否有象SQLServer能取出数据库中所有的表
- 如何利用ado对象从sql server 数据库中取出库内所有的表名!!!!!!!
- 急!!!如何在delphi中从数据库的表中取出一个cust_no的所有值
- 数据库选择所有表问题
- 从数据库得到所有的表
- 数据库表所有者的问题
- 如何从names数据库中取出所有“部门”信息,放入一个设置为“列表框”的域中?
- 怎样从sql server数据库中取出本周内的所有记录
- 用microsoft 的TreeView WebControl,树中的所有节点都是从数据库取出。。
- =========== 如何取出 SQL Server 服务器里 所有的数据库名 ? =============




