如何将某数据库里存在的所有表名查找出来

liujianliang 2008-01-21 05:43:45
如何将某数据库里存在的所有表名查找出来
...全文
177 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
pengxuan 2008-01-23
  • 打赏
  • 举报
回复

select name from sysobjects where type='U'
acuerdo 2008-01-23
  • 打赏
  • 举报
回复
select name from sysobjects where type='U'
wzy_love_sly 2008-01-22
  • 打赏
  • 举报
回复
恩,那用茶杯的
dawugui 2008-01-22
  • 打赏
  • 举报
回复
只要连接上了库,这个语句就是查询的当前库.
ojuju10 2008-01-22
  • 打赏
  • 举报
回复
select name from 库名.dbo.sysobjects where xtype='u'

最好不要绑定库名,因为假如你的数据库名称改了之后,程序也要改动,建议还是动态的获取库名
ojuju10 2008-01-22
  • 打赏
  • 举报
回复

select name from sysobjects where xtype='u'
netcup 2008-01-21
  • 打赏
  • 举报
回复
exec sp_msforeachtable "command1"
wzy_love_sly 2008-01-21
  • 打赏
  • 举报
回复
select name from 库名.dbo.sysobjects where type='U'
哪都一样
liujianliang 2008-01-21
  • 打赏
  • 举报
回复
各位的句子都是在查询分析器里写的吧?
但我希望是在winform里写这个
关键是这个指定数据库名怎么写??
比如:在数据库student里的所有表名
areswang 2008-01-21
  • 打赏
  • 举报
回复
use db
go
select name from sysobjects where type='U'
yangjiexi 2008-01-21
  • 打赏
  • 举报
回复

select name from sysobjects
where xtype='u'
--忘加条件了,呵呵!
dawugui 2008-01-21
  • 打赏
  • 举报
回复
select name from sysobjects where type='U'

/*
name
-------------------------------------
titleauthor
stores
sales
roysched
discounts
jobs
pub_info
employee
税率表
authors
publishers
titles

(所影响的行数为 12 行)

*/
yangjiexi 2008-01-21
  • 打赏
  • 举报
回复

select name from sysobjects
liangCK 2008-01-21
  • 打赏
  • 举报
回复
select name from sysobjects where xtype="U"

34,587

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧