数据库的问题

New919 2005-11-27 12:26:28
怎么把一台SQLSERVER服务器里面所有的数据库查出来?
怎么把每一个数据库里面的用户表查出来?
高手帮忙~
...全文
79 2 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
点点星灯 2005-11-27
  • 打赏
  • 举报
回复

exec sp_MSforeachdb N'use [?]select dbname=db_name(),username=user_name()'
vivianfdlpw 2005-11-27
  • 打赏
  • 举报
回复
exec sp_msforeachtable 'print ''?'''

or

declare @cursor cursor
,@name varchar(20)
set @cursor=cursor for select name from sysobjects where xtype='U'
open @cursor
fetch next from @cursor into @name

while @@fetch_status=0
begin
print @name
fetch next from @cursor into @name
end

close @cursor
deallocate @cursor

27,582

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 应用实例
社区管理员
  • 应用实例社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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